--sortie <= '0' when (WR = '1') and (RD = '0') and ( ((A0 = '1') and ((D_RW = Least) or (D_RW = Most) or (D_RW = LeastMost))) or (A0 = '0') ) else '1';
--sortie <= '0' when (WR = '1') and (RD = '0') and (A0 = '0') and ((D_RW = Least) or (D_RW = Most) or (D_RW = LeastMost)) else '1';
-- '0' force the output of the timer to 0, '1' allow the counter to modify the output of the timer
Sortie<='0'when((WR_q='1')and(RD_q='0')and(
((A0_q='1')and(not(D_RW_q=Latch)))--Receive controle word without counter latch command
or(A0_q='0')--Load data in the counter
))
else'1';
-- '0' = false, '1' = true
charg_d<='1'when((WR_q='1')and(RD_q='0')and(A0_q='0')and(-- test if instruction is a load of counter
((EtatW_q=L)and(RW_op_q=Least))-- if instruction load only lsb bytes
or((EtatW_q=M)and((RW_op_q=Most)or(RW_op_q=LeastMost)))-- if instruction load only msb bytes or all bytes (and reading MSB bytes)
))
else'0';
latch_d_temp<='1'
when((WR_q='1')and(RD_q='0')and(A0_q='1')and(D_RW_q=Latch))-- if instruction is writing a control world
else'0'when(((WR_q='0')and(RD_q='1')and(A0_q='0')and(-- test if instruction is a read of counter
((EtatW_q=L)and(RW_op_q=Least))-- if instruction readonly lsb bytes
or((EtatW_q=M)and((RW_op_q=Most)or(RW_op_q=LeastMost)))-- if instruction readonly msb bytes or all bytes (and reading MSB bytes)
))
or((WR_q='1')and(RD_q='0')and(A0_q='1')and(not(D_RW_q=Latch)))-- if instruction is writing a control world without latch as RW command
)
elselatch_d_q;-- keep the previous value of latch
RW_op<=D_RW_qwhen((WR_q='1')and(RD_q='0')and(A0_q='1')and(not(D_RW_q=Latch)))-- if instruction is writing a control world without latch as RW command
elseRW_op_q;-- keep the previous value of RW_op
d_buf_in_tempLSB<=D_qwhen((WR_q='1')and(RD_q='0')and(A0_q='0')and(EtatW_q=L))-- transfer of the LSB from D to d_buf_in(7 downto 0)
else"00000000"when((WR_q='1')and(RD_q='0')and(A0_q='0')and(EtatW_q=M)and(RW_op_q=Most))-- if we only load the MSB force x"00" to d_buf_in(7 downto 0)
elsed_buf_inLSB_q;-- keep the previous value of the variable
d_buf_in_tempMSB<=D_qwhen((WR_q='1')and(RD_q='0')and(A0_q='0')and(EtatW_q=M))-- transfer of the MSB from D to d_buf_in(15 downto 8)
else"00000000"when((WR_q='1')and(RD_q='0')and(A0_q='0')and(EtatW_q=L)and(RW_op_q=Least))-- if we only load the MSB force x"00" to d_buf_in(15 downto 8)
elsed_buf_inMSB_q;-- keep the previous value of the variable
-- the CPU maintain (WR='0') and (RD='1') to keep value of dbuf_out on D if the CPU prepare an other instruction dialogue CPU set D as HiZ so the CPU can write on it
D<=d_buf_outLSBwhen((WR_q='0')and(RD_q='1')and(A0_q='0')and(EtatW_q=L)and(WR='0')and(RD='1'))-- transfer of the LSB from d_buf_out( 7 downto 0) to D
elsed_buf_outMSBwhen((WR_q='0')and(RD_q='1')and(A0_q='0')and(EtatW_q=M)and(WR='0')and(RD='1'))-- transfer of the MSB from d_buf_out(15 downto 8) to D
else"ZZZZZZZZ";-- other instruction does not impact the bus
EtatW<=Mwhen(((WR_q='1')and(RD_q='0')and(A0_q='0')and(EtatW_q=L)and(RW_op_q=LeastMost))-- if loading in leastMost mode and EtatW_q = L
or((WR_q='1')and(RD_q='0')and(A0_q='1')and(D_RW_q=Most)))-- if writing control word D_RW and mode is leastMost or Least
elseLwhen(((WR_q='1')and(RD_q='0')and(A0_q='0')and(EtatW_q=M)and(RW_op_q=LeastMost))-- if loading in leastMost mode and EtatW_q = M
or((WR_q='1')and(RD_q='0')and(A0_q='1')and((D_RW_q=LeastMost)or(D_RW_q=Least))))-- if writing control word D_RW and mode is Most
elseEtatW_q;-- keep previous value
EtatR<=Mwhen(((WR_q='0')and(RD_q='1')and(A0_q='0')and(EtatW_q=L)and(RW_op_q=LeastMost))-- if reading in leastMost mode and EtatW_q = L
or((WR_q='1')and(RD_q='0')and(A0_q='1')and(D_RW_q=Most)))-- if writing control word D_RW and mode is leastMost or Least
elseLwhen(((WR_q='0')and(RD_q='1')and(A0_q='0')and(EtatW_q=M)and(RW_op_q=LeastMost))-- if reading in leastMost mode and EtatW_q = M
or((WR_q='1')and(RD_q='0')and(A0_q='1')and((D_RW_q=LeastMost)or(D_RW_q=Least))))-- if writing control word D_RW and mode is Most