M1: spi_rom_control Architecture (mit Fehler)
This commit is contained in:
@@ -56,7 +56,7 @@ begin
|
||||
port map (
|
||||
clk => clk,
|
||||
addr => addr,
|
||||
dout => data
|
||||
dout => data_rom
|
||||
);
|
||||
|
||||
Control_Inst: entity work.spi_rom_control
|
||||
@@ -73,6 +73,6 @@ begin
|
||||
m_data => data,
|
||||
m_valid => valid,
|
||||
m_ready => ready
|
||||
)
|
||||
);
|
||||
|
||||
end rtl;
|
||||
|
||||
@@ -33,12 +33,13 @@ begin
|
||||
begin
|
||||
reset <= '0' after 100 * clk_half_period;
|
||||
|
||||
wait for 45 us;
|
||||
wait until rising_edge(clk);
|
||||
reset <= '1';
|
||||
wait for 1 us;
|
||||
wait until rising_edge(clk);
|
||||
reset <= '0';
|
||||
-- wait for 45 us;
|
||||
-- wait until rising_edge(clk);
|
||||
-- reset <= '1';
|
||||
-- wait for 1 us;
|
||||
-- wait until rising_edge(clk);
|
||||
-- reset <= '0';
|
||||
wait;
|
||||
end process;
|
||||
|
||||
dut: entity work.spi2display
|
||||
|
||||
@@ -18,18 +18,24 @@ entity spi_rom_control is
|
||||
-- Streaming Interface spi_transmitter
|
||||
m_data : out std_logic_vector(7 downto 0);
|
||||
m_valid : out std_logic;
|
||||
m_ready : in std_logic;
|
||||
m_ready : in std_logic
|
||||
);
|
||||
end entity;
|
||||
|
||||
|
||||
architecture rtl of spi_rom_control is
|
||||
|
||||
-- Steuersignale fuer Zustandsmaschine
|
||||
signal CtrlBits : std_logic_vector(1 downto 0);
|
||||
signal CntAddrEn : std_logic;
|
||||
signal CntAddrRst : std_logic;
|
||||
signal RegDataEn : std_logic;
|
||||
|
||||
-- Finite State Machine
|
||||
type state_t is (S_ReadRom, S_ProvideData, S_DeadEnd, S_ERROR);
|
||||
signal state : state_t := S_ReadRom;
|
||||
signal state_next : state_t;
|
||||
|
||||
begin
|
||||
|
||||
RegData: process
|
||||
@@ -37,9 +43,10 @@ begin
|
||||
begin
|
||||
wait until rising_edge(clk);
|
||||
if RegDataEn = '1' then
|
||||
m_data <= din(7 downto 0);
|
||||
CtrlBits <= din(9 downto 8);
|
||||
Q := din;
|
||||
end if;
|
||||
m_data <= Q(7 downto 0);
|
||||
CtrlBits <= Q(9 downto 8);
|
||||
end process;
|
||||
|
||||
CntAddr: process
|
||||
@@ -47,12 +54,89 @@ begin
|
||||
begin
|
||||
wait until rising_edge(clk);
|
||||
if CntAddrRst = '1' then
|
||||
cntVal := 0;
|
||||
cntVal := (others=>'0');
|
||||
elsif CntAddrEn = '1' then
|
||||
cntVal := cntVal + 1;
|
||||
end if;
|
||||
addr <= std_logic_vector(cntVal);
|
||||
end process;
|
||||
|
||||
-- Prozesse fuer endlichen Automaten
|
||||
Transition: process(state, reset, m_ready, CtrlBits)
|
||||
begin
|
||||
-- Default-Werte fuer Folgezustand und Mealy-Ausgaenge
|
||||
state_next <= S_ERROR;
|
||||
CntAddrEn <= '0';
|
||||
CntAddrRst <= '0';
|
||||
|
||||
-- Berechnung des Folgezustands und der Mealy-Ausgaenge
|
||||
case state is
|
||||
when S_ReadRom =>
|
||||
if reset = '1' then
|
||||
state_next <= S_ReadRom;
|
||||
CntAddrRst <= '1';
|
||||
else
|
||||
state_next <= S_ProvideData;
|
||||
end if;
|
||||
when S_ProvideData =>
|
||||
if reset = '1' then
|
||||
state_next <= S_ReadRom;
|
||||
CntAddrRst <= '1';
|
||||
elsif m_ready = '0' then
|
||||
state_next <= S_ProvideData;
|
||||
elsif m_ready = '1' then
|
||||
if CtrlBits = "10" then
|
||||
state_next <= S_DeadEnd;
|
||||
elsif CtrlBits = "00" then
|
||||
state_next <= S_ReadRom;
|
||||
CntAddrEn <= '1';
|
||||
elsif CtrlBits = "01" or CtrlBits = "11" then
|
||||
state_next <= S_ReadRom;
|
||||
CntAddrRst <= '1';
|
||||
end if;
|
||||
end if;
|
||||
when S_DeadEnd =>
|
||||
if reset = '1' then
|
||||
state_next <= S_ReadRom;
|
||||
CntAddrRst <= '1';
|
||||
else
|
||||
state_next <= S_DeadEnd;
|
||||
end if;
|
||||
when S_ERROR =>
|
||||
if reset = '1' then
|
||||
state_next <= S_ReadRom;
|
||||
CntAddrRst <= '1';
|
||||
else
|
||||
state_next <= S_ERROR;
|
||||
CntAddrEn <= 'X';
|
||||
CntAddrRst <= 'X';
|
||||
end if;
|
||||
end case;
|
||||
end process;
|
||||
|
||||
-- Register fuer Zustand und Ausgaenge
|
||||
Reg: process
|
||||
begin
|
||||
wait until rising_edge(clk);
|
||||
|
||||
-- Zustandswechsel
|
||||
state <= state_next;
|
||||
|
||||
-- Berechnung der Moore-Ausgaenge
|
||||
-- Default-Werte
|
||||
m_valid <= '0';
|
||||
RegDataEn <= '0';
|
||||
|
||||
case state_next is
|
||||
when S_ReadRom =>
|
||||
RegDataEn <= '1';
|
||||
when S_ProvideData =>
|
||||
m_valid <= '1';
|
||||
when S_DeadEnd =>
|
||||
null;
|
||||
when S_ERROR =>
|
||||
m_valid <= 'X';
|
||||
RegDataEn <= 'X';
|
||||
end case;
|
||||
end process;
|
||||
end architecture;
|
||||
@@ -91,7 +91,7 @@ begin
|
||||
end process;
|
||||
|
||||
-- Prozesse fuer endlichen Automaten
|
||||
Transition: process(reset, CntSckTc, CntBitsTC, s_valid)
|
||||
Transition: process(state, reset, CntSckTc, CntBitsTC, s_valid)
|
||||
begin
|
||||
-- Default-Werte fuer Folgezustand und Mealy-Ausgaenge
|
||||
state_next <= S_ERROR;
|
||||
|
||||
@@ -31,23 +31,40 @@ if {1} {
|
||||
}
|
||||
|
||||
if {1} {
|
||||
add wave -divider "Interne Signale"
|
||||
add wave -noupdate -ascii /spi2display_tb/dut/SPI_Transmitter_Inst/data
|
||||
add wave -noupdate -hexadecimal /spi2display_tb/dut/SPI_Transmitter_Inst/addr
|
||||
add wave -divider "Steuerwerk"
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/Steuerwerk/state
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/Steuerwerk/state_next
|
||||
add wave -divider "Steuersignale"
|
||||
add wave -noupdate -divider {Interne Signale}
|
||||
add wave -noupdate /spi2display_tb/dut/addr
|
||||
add wave -noupdate -radix ascii /spi2display_tb/dut/data_rom
|
||||
add wave -noupdate -radix ascii /spi2display_tb/dut/data
|
||||
add wave -noupdate /spi2display_tb/dut/valid
|
||||
add wave -noupdate /spi2display_tb/dut/ready
|
||||
add wave -noupdate -divider spi_rom_control
|
||||
add wave -noupdate -divider Steuerwerk
|
||||
add wave -noupdate /spi2display_tb/dut/Control_Inst/state
|
||||
add wave -noupdate /spi2display_tb/dut/Control_Inst/state_next
|
||||
add wave -noupdate /spi2display_tb/dut/Control_Inst/CtrlBits
|
||||
add wave -noupdate /spi2display_tb/dut/Control_Inst/CntAddrEn
|
||||
add wave -noupdate /spi2display_tb/dut/Control_Inst/CntAddrRst
|
||||
add wave -noupdate /spi2display_tb/dut/Control_Inst/RegDataEn
|
||||
add wave -noupdate -divider Rechenwerk
|
||||
add wave -noupdate -label RegData -radix ascii /spi2display_tb/dut/Control_Inst/RegData/Q
|
||||
add wave -noupdate -label CntAddr /spi2display_tb/dut/Control_Inst/CntAddr/cntVal
|
||||
}
|
||||
|
||||
if {1} {
|
||||
add wave -noupdate -divider Steuerwerk
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/state
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/state_next
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/CntSckTc
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/CntBitsTC
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/CtrlBits
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/cntAddrEn
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/cntAddrRst
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/CntSckRst
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/RegDataLd
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/RegDataShift
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/RegDataEn
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/CntBitsEn
|
||||
add wave -divider "Rechenwerk"
|
||||
add wave -noupdate -unsigned -label CounterBits /spi2display_tb/dut/SPI_Transmitter_Inst/Rechenwerk/CntBits/cntVal
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/CntBitsTC
|
||||
add wave -noupdate /spi2display_tb/dut/SPI_Transmitter_Inst/CntBitsRst
|
||||
add wave -noupdate -divider Rechenwerk
|
||||
add wave -noupdate -label RegData /spi2display_tb/dut/SPI_Transmitter_Inst/RegData/Q
|
||||
add wave -noupdate -label CntSck /spi2display_tb/dut/SPI_Transmitter_Inst/CntSck/cntVal
|
||||
add wave -noupdate -label CntBits /spi2display_tb/dut/SPI_Transmitter_Inst/CntBits/cntVal
|
||||
}
|
||||
|
||||
run 1000 us
|
||||
Reference in New Issue
Block a user