8ビット演算回路
2007年6月29日
先日の回路を組み合わせて、8ビットどうしの演算をするための回路を設計した。実行できるのは、加算・減算・NAND・NOR・右シフト・左シフト。設計中のコンピューターにおける、inc/dec 以外の演算を網羅している。

なお、m1, m2, m4 は、コマンドラインのデータ信号。
この回路のシミュレータは、ここから実行可能。回路に相当する部分のソースコードは、以下のとおり。

なお、m1, m2, m4 は、コマンドラインのデータ信号。
この回路のシミュレータは、ここから実行可能。回路に相当する部分のソースコードは、以下のとおり。
$as=array();
for ($i=0;$i<8;$i++) {
if (0<$i) $prev=$as[$i-1]->output();
else $prev=array('o'=>0,'co'=>0);
$as[$i]=new add_sub($com->getData('d0'),
$com->getData('d1'),
$com->getData('d2'),
$com->getData('d3'),
$com->getData('d4'),
$d1->getData('d'.$i),
$d2->getData('d'.$i),
$prev['co'],
'?');
}
$hex=0;
for ($i=0;$i<8;$i++) {
if (0<$i) $prev=$as[$i-1]->output();
else $prev=array('o'=>0,'co'=>0);
if ($i<7) $next=$as[$i+1]->output();
else $next=array('o'=>0,'co'=>0);
$as[$i]->set($com->getData('d0'),
$com->getData('d1'),
$com->getData('d2'),
$com->getData('d3'),
$com->getData('d4'),
$d1->getData('d'.$i),
$d2->getData('d'.$i),
$prev['co'],
$next['co']);
$data=$as[$i]->output();
echo '<tr><td>d'.(int)$i.'</td><td>'.(int)$data['o'].'</td></tr>';
$hex=$hex+$data['o']*pow(2,$i);
}
$as0=$as[0]->output();
$as7=$as[7]->output();
$carry=NAND74::output($com->getData('d1'),$com->getData('d4'));
$carry=NAND74::output($carry,$carry);
$carry=NAND74::output($carry,NOT74::output($com->getData('d2')));
$nand1=NAND74::output($as0['co'],NOT74::output($carry));
$nand2=NAND74::output($as7['co'],$carry);
$carry=NAND74::output($nand1,$nand2);