X



何でブール代数がプログラムに使えるか教えろ

■ このスレッドは過去ログ倉庫に格納されています
008382
垢版 |
2019/04/16(火) 21:55:25.40ID:kcG0S8Ob
ついでにこんなベンチを書いてシミュレーションしてみた。
library IEEE,WORK; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; use IEEE.std_logic_arith.all;
use WORK.FuncPrintf.all;
entity Test0010_tb is
end Test0010_tb;
architecture testbench of Test0010_tb is
  component Test0010
    port
    (  a,b,c,d : in  boolean
    ;  o    : out  boolean
    );
  end component;
  signal a,b,c,d,o  : boolean  ;
  signal x      : std_logic_vector(4 downto 0) ;
begin
  u : Test0010 port map (a,b,c,d,o);
  a <= x(0) = '1';
  b <= x(1) = '1';
  c <= x(2) = '1';
  d <= x(3) = '1';
  x(4) <= '1' when o else '0';
  process
  begin
    for i in 0 to 15 loop
      x(3 downto 0)  <= conv_std_logic_vector(i,4); wait for 1 ns;
      printf("%02X\n",conv_integer(x));
    end loop;
    assert FALSE report "End." severity FAILURE;
  end process;
end testbench;
008482
垢版 |
2019/04/16(火) 21:55:49.77ID:kcG0S8Ob
結果は左から順に下記。
  o <= ((c or d)and(a=c)and(b = d)) or ((not(c or d))and((a = c)or(b = d)));
  o <= (not c)and(not d)and(b=d);
  o <= (a=c)or(b=d);
  o <= (a=c)and(b=d);

結果。
# 10 10 10 10
# 11 11 11 01
# 12 02 12 02
# 03 03 03 03
# 04 04 14 04
# 15 05 15 15
# 06 06 06 06
# 07 07 17 07
# 08 08 18 08
# 09 09 09 09
# 1A 0A 1A 1A
# 0B 0B 1B 0B
# 0C 0C 0C 0C
# 0D 0D 1D 0D
# 0E 0E 1E 0E
# 1F 0F 1F 1F
0085デフォルトの名無しさん
垢版 |
2020/03/24(火) 13:29:39.50ID:WT9cP8p5
>>1
>>26
0086デフォルトの名無しさん
垢版 |
2020/03/26(木) 22:22:51.76ID:ljFDlwQq
プロセスとスレッドの違いを教えて
0087デフォルトの名無しさん
垢版 |
2020/03/27(金) 14:38:34.98ID:9RtDMjhb
続きはしかるべきスレで
■ このスレッドは過去ログ倉庫に格納されています

ニューススポーツなんでも実況