Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/components/PartDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { CCComponent } from "../store/component";
import { IntrinsicComponentDefinition } from "../store/intrinsics/base";
import { definitionByComponentId } from "../store/intrinsics/definitions";
import { type TruthTable, truthTableOf } from "../store/intrinsics/truthTable";
import { BitNotationContext } from "./bitNotation";
import { MarkedText } from "./MarkedText";
import { TruthTableView } from "./TruthTableView";

Expand Down Expand Up @@ -33,13 +34,17 @@ export function pinNotesOf(
export function PartDescription({ component }: { component: CCComponent }) {
const messages = useMessages();
const definition = definitionByComponentId.get(component.id);
// A part is the same outside the stages, so its table writes bits as the editor shows
// them, not as the stage tables do
return (
<PartDescriptionView
name={component.name}
summary={partSummary(messages, component)}
notes={definition ? pinNotesOf(messages, definition) : []}
table={definition ? truthTableOf(definition) : null}
/>
<BitNotationContext value="onOff">
<PartDescriptionView
name={component.name}
summary={partSummary(messages, component)}
notes={definition ? pinNotesOf(messages, definition) : []}
table={definition ? truthTableOf(definition) : null}
/>
</BitNotationContext>
);
}

Expand Down
14 changes: 8 additions & 6 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const stageTexts: Record<TutorialStageId, StageTexts> = {
"half-adder": {
title: "Adding one digit",
goal: [
"From here on, think of [ON] as [1] and [OFF] as [0], and the tables write them that way too. Then {A} + {B} is 0, 1 or 2. Binary writes numbers with only 0 and 1: just as 9 + 1 carries over and becomes 10 in everyday numbers, 1 + 1 carries over and becomes 10 in binary. So 0, 1 and 2 are [00], [01] and [10] in two digits. A digit of a binary number is called a bit.",
"From here on, think of [ON] as [1] and [OFF] as [0], and the tables of the stages' circuits write them that way too. Then {A} + {B} is 0, 1 or 2. Binary writes numbers with only 0 and 1: just as 9 + 1 carries over and becomes 10 in everyday numbers, 1 + 1 carries over and becomes 10 in binary. So 0, 1 and 2 are [00], [01] and [10] in two digits. A digit of a binary number is called a bit.",
"Output the left digit (the twos digit) to {C} and the right digit (the ones digit) to {S}. {C} is called the carry and {S} the sum, and this circuit is called a half adder.",
],
steps: [],
Expand Down Expand Up @@ -81,7 +81,7 @@ const stageTexts: Record<TutorialStageId, StageTexts> = {
],
steps: [
"Place a {FlipFlop}. A {FlipFlop} outputs what it received at the time step before, and [0000] at the first time step. Connect its output to {Count} and to the {7seg} at the top right.",
'Place a {Const}. A {Const} always outputs the value written in it. Change [00000000] in its box to [0001] and press <constApply> (four bits, to match the {B} it connects to). The "4 bits" below the box is the number of bits of the value.',
'Place a {Const}. A {Const} always outputs the value set in its box. Change [00000000] in its box to [0001] and press <constApply> (four bits, to match the {B} it connects to). The "4 bits" below the box is the number of bits of the value.',
'Place "{Adding four digits}". Connect the output of the {FlipFlop} to its {A}, the {Const} to its {B}, and its {S} to the input of the {FlipFlop}. Then the number the {FlipFlop} outputs plus 1 comes out of the {FlipFlop} at the next time step. {C} is not used.',
"Press the play button <play> and go through the time steps with the right arrow <nextStep>. Press <auto> to go on by itself, one time step a second. The circuit works when the {Display} at the top right shows 0 to F in turn.",
],
Expand Down Expand Up @@ -140,7 +140,8 @@ export const en = {
AGGREGATE: "Joins values into one, the upper pins as the higher digits.",
FLIPFLOP:
"Outputs what it received at the time step before. At the first time step, it outputs [OFF], or a value of all [0] bits if its output has two or more bits.",
CONST: "Always outputs the value written in it.",
CONST:
"Always outputs the value set in its box. To change it, change the value in the box while editing and press <constApply>. The output has as many bits as shown below the box.",
BROADCAST: "Repeats a one-bit value over two or more bits.",
ANDN: "[ON] only when every bit of {In} is [1].",
ORN: "[ON] when any bit of {In} is [1].",
Expand All @@ -155,8 +156,8 @@ export const en = {
} satisfies Record<CCIntrinsicComponentType, string>,
pinBitWidth: (pinName: string, canAddPins: boolean) =>
canAddPins
? `The number in an {${pinName}} pin is its number of bits. Click an {${pinName}} pin while editing, and a field for each {${pinName}} pin appears, from the top. <pinAdd> adds a field at the bottom, and <pinRemove> removes the bottom one. Change the numbers in the fields and press <pinApply>, and the {${pinName}} pins follow the fields.`
: `The number in the {${pinName}} pin is its number of bits. To change it, click the pin while editing, change the number in the field and press <pinApply>.`,
? `The number in an {${pinName}} pin is its number of bits. Click an {${pinName}} pin while editing, and a box for each {${pinName}} pin appears, from the top. <pinAdd> adds a box at the bottom, and <pinRemove> removes the bottom one. Change the numbers in the boxes and press <pinApply>, and the {${pinName}} pins follow the boxes.`
: `The number in the {${pinName}} pin is its number of bits. To change it, click the pin while editing, change the number in the box and press <pinApply>.`,
about: (name: string) => `About ${name}`,
ofStage: "Available parts",
},
Expand Down Expand Up @@ -253,7 +254,8 @@ export const en = {
parts: "Parts",
goalHeading: "Goal",
stepsHeading: "Steps",
digitsLegend: "The tables write ON as 1 and OFF as 0.",
digitsLegend:
"The tables of the stages' circuits write ON as 1 and OFF as 0.",
check: "Check",
checking: "Checking…",
passed: "Cleared! The circuit works for every combination of the inputs.",
Expand Down
9 changes: 5 additions & 4 deletions src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const ja: Messages = {
AGGREGATE: "上のピンを上の桁として、値を1つにまとめる。",
FLIPFLOP:
"1つ前のステップで受け取った値を出す。最初のステップでは [OFF] を、出力が2ビット以上ならすべてのビットが [0] の値を出す。",
CONST: "中に書いた値をいつも出す。",
CONST:
"欄で決めた値をいつも出す。値は、編集中に欄を書きかえて<constApply>を押すと変わる。出力のビット数は、欄の下に表示されるビット数。",
BROADCAST: "1ビットの値を、同じ値が並んだ2ビット以上の値に広げる。",
ANDN: "{In} のビットがすべて [1] のときだけ [ON]。",
ORN: "{In} のどれかのビットが [1] なら [ON]。",
Expand Down Expand Up @@ -135,7 +136,7 @@ export const ja: Messages = {
parts: "部品",
goalHeading: "目標",
stepsHeading: "手順",
digitsLegend: "表では、ON を 1、OFF を 0 と書いています。",
digitsLegend: "課題の回路の表では、ON を 1、OFF を 0 と書いています。",
check: "確かめる",
checking: "確かめています…",
passed: "クリア!どの入力の組み合わせでも正しく動きます。",
Expand Down Expand Up @@ -193,7 +194,7 @@ export const ja: Messages = {
"half-adder": {
title: "1桁の足し算",
goal: [
"ここからは [ON] を [1]、[OFF] を [0] と考え、表もそう書きます。すると、{A}+{B} は 0、1、2 のどれかです。2進数では、0 と 1 だけで数を書きます。ふだんの数で 9+1 が繰り上がって 10 になるように、2進数では 1+1 が繰り上がって 10 になります。そのため、0、1、2 は2桁で [00]、[01]、[10] です。2進数の1桁を「ビット」といいます。",
"ここからは [ON] を [1]、[OFF] を [0] と考え、課題の回路の表もそう書きます。すると、{A}+{B} は 0、1、2 のどれかです。2進数では、0 と 1 だけで数を書きます。ふだんの数で 9+1 が繰り上がって 10 になるように、2進数では 1+1 が繰り上がって 10 になります。そのため、0、1、2 は2桁で [00]、[01]、[10] です。2進数の1桁を「ビット」といいます。",
"左の桁(2の位)を {C} に、右の桁(1の位)を {S} に出しましょう。{C} を「桁上がり」、{S} を「和」といい、この回路を「半加算器」といいます。",
],
steps: [],
Expand Down Expand Up @@ -225,7 +226,7 @@ export const ja: Messages = {
],
steps: [
"{FlipFlop} を置きます。{FlipFlop} は、1つ前のステップで受け取った値を出します。最初のステップでは [0000] を出します。{FlipFlop} の出力を、{Count} と、右上の {7seg} につなぎます。",
"{Const} を置きます。{Const} は、中に書いた値をいつも出します。欄の [00000000] を [0001] に書きかえて、<constApply>を押します(つなぐ先の {B} に合わせて、4ビットで書きます)。欄の下の「4 ビット」は、書いた値のビット数です。",
"{Const} を置きます。{Const} は、欄で決めた値をいつも出します。欄の [00000000] を [0001] に書きかえて、<constApply>を押します(つなぐ先の {B} に合わせて、4ビットで書きます)。欄の下の「4 ビット」は、書いた値のビット数です。",
"「{4桁の足し算}」を置き、{FlipFlop} の出力を {A} に、{Const} を {B} に、{S} を {FlipFlop} の入力につなぎます。こうすると、{FlipFlop} が出している数に 1 を足した数が、次のステップで {FlipFlop} から出てきます。{C} は使いません。",
"再生ボタン<play>を押し、右の矢印<nextStep>でステップを進めます。<auto>を押すと、1秒に1ステップずつひとりでに進みます。右上の {Display} に 0 から F が順に出れば、うまく動いています。",
],
Expand Down
Loading