process (clock, reset_N)
begin
if reset_N = '0' then
TxWritten <= '0';
else
if clearTxWritten = '1' then
TxWritten <= '0';
elsif write = '1' and address = c_TX then
Tx <= writeData;
TxWritten <= '1';
end if;
end if;
end process;
Sorry. I agree, this is probably a typo.
The fix is
-- else
elsif clock'event and clock='1' then
I missed it (and maybe Ian did too)
because it happens to run my
testbench fine hitting both edges as it does.
I also found a range error this time around
that must have passed on an older modelsim version.
-- TxBitCount: integer range 0 to 8;
TxBitCount: integer range 0 to 9;
PS. again, no disrespect to Ian. In fact, he does make the point that
the snippets that are labelled "bad code" are harder to get right which
this discussion probably shows.
I agree. The main thing I got from Ian's articles is
the idea that you can describe as many registers
as you like in a single process.
The idea I added while editing this design
was that no signal declarations are actually needed in
a single process entity, and that procedures can
be used to match any design to a fixed template.
-- Mike Treseler
____________________________
# vsim -do {run -all} -c test_duff
# // ModelSim SE 6.1c Nov 17 2005 Linux 2.6.5-7.201-smp
# Loading /flip/usr1/modeltech/linux/../std.standard
# Loading /flip/usr1/modeltech/linux/../ieee.std_logic_1164(body)
# Loading /flip/usr1/modeltech/linux/../ieee.numeric_std(body)
# Loading /flip/usr1/modeltech/linux/../ieee.std_logic_arith(body)
# Loading /flip/usr1/modeltech/linux/../ieee.std_logic_unsigned(body)
# Loading work.test_duff(sim)
# Loading work.uart_vhdl(duff)
# run -all
# ** Note: Saw reset rise and fall OK
# ** Note: ___Step 0
# ** Note: ____________ saw 72 as expected
# ** Note: ___Step 1
# ** Note: ____________ saw 66 as expected
# ** Note: ___Step 2
# ** Note: ____________ saw 229 as expected
# ** Note: ___Step 3
# ** Note: ____________ saw 137 as expected
# ** Note: ___Step 4
# ** Note: ____________ saw 106 as expected
# ** Note: ___Step 5
# ** Note: ____________ saw 126 as expected
# ** Note: ___Step 6
# ** Note: ____________ saw 48 as expected
# ** Note: ___Step 7
# ** Note: ____________ saw 239 as expected
# ** Note: ___Step 8
# ** Note: ____________ saw 46 as expected
# ** Note: ___Step 9
# ** Note: ____________ saw 6 as expected
# ** Note: ___Step 10
# ** Note: ____________ saw 157 as expected
# ** Note: ___Step 11
# ** Note: ____________ saw 36 as expected
# ** Note: ___Step 12
# ** Note: ____________ saw 161 as expected
# ** Note: ___Step 13
# ** Note: ____________ saw 241 as expected
# ** Note: ___Step 14
# ** Note: ____________ saw 199 as expected
# ** Note: ___Step 15
# ** Note: ____________ saw 181 as expected
# ** Note: ___Step 16
# ** Note: ____________ saw 191 as expected
# ** Note: ___Step 17
# ** Note: ____________ saw 92 as expected
# ** Note: ___Step 18
# ** Note: ____________ saw 46 as expected
# ** Note: ___Step 19
# ** Note: ____________ saw 151 as expected
# ** Note: ___Step 20
# ** Note: ____________ saw 72 as expected
# ** Note: ___Step 21
# ** Note: ____________ saw 36 as expected
# ** Note: ___Step 22
# ** Note: ____________ saw 18 as expected
# ** Note: ___Step 23
# ** Note: ____________ saw 137 as expected
# ** Note: ___Step 24
# ** Note: ____________ saw 199 as expected
# ** Note: ___Step 25
# ** Note: ____________ saw 96 as expected
# ** Note: ___Step 26
# ** Note: ____________ saw 48 as expected
# ** Note: ___Step 27
# ** Note: ____________ saw 24 as expected
# ** Note: ___Step 28
# ** Note: ____________ saw 12 as expected
# ** Note: ___Step 29
# ** Note: ____________ saw 6 as expected
# ** Note: ___Step 30
# ** Note: ____________ saw 131 as expected
# ** Note: ___Step 31
# ** Note: ____________ saw 66 as expected
# ** Note: ___ALL PASS___
VSIM 2>