OpenCores
URL https://opencores.org/ocsvn/openverifla/openverifla/trunk

Subversion Repositories openverifla

[/] [openverifla/] [trunk/] [openverifla_2.4/] [vhdl/] [verifla/] [send_capture_of_verifla.vhd] - Blame information for rev 46

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 46 laurentiud
-- 20180820-1740
2
-- Author: Laurentiu Duca
3
-- License: GNU GPL
4
-----------------------------------------------------
5
 
6
library IEEE;
7
use IEEE.STD_LOGIC_1164.ALL;
8
use IEEE.NUMERIC_STD.ALL;
9
--use ieee.std_logic_arith.all;  
10
--use ieee.std_logic_unsigned.all;
11
use work.common_internal_verifla.all;
12
 
13
-----------------------------------------------------
14
 
15
entity send_capture_of_verifla is
16
        port (clk, rst_l, baud_clk_posedge: in std_logic;
17
                sc_run: in std_logic;
18
                ack_sc_run, sc_done: out std_logic;
19
                mem_port_B_address: out std_logic_vector(LA_MEM_ADDRESS_BITS-1 downto 0);
20
                mem_port_B_dout: in std_logic_vector(LA_MEM_WORDLEN_BITS-1 downto 0);
21
                xmit_doneH: in std_logic;
22
                xmitH: out std_logic;
23
                xmit_dataH: out std_logic_vector(7 downto 0));
24
end send_capture_of_verifla;
25
 
26
-----------------------------------------------------
27
 
28
architecture send_capture_of_verifla_arch of send_capture_of_verifla is
29
 
30
        constant LA_MEM_LAST_ADDR_SLV: std_logic_vector(LA_MEM_ADDRESS_BITS-1 downto 0)
31
                := std_logic_vector(to_unsigned(LA_MEM_LAST_ADDR, LA_MEM_ADDRESS_BITS));
32
        constant USERCMD_RESET: std_logic_vector(7 downto 0) :=x"00";
33
        constant USERCMD_RUN: std_logic_vector(7 downto 0) :=x"01";
34
        type state_type is (SC_STATE_IDLE, SC_STATE_ACK_SC_RUN,
35
                SC_STATE_SET_MEMADDR_TO_READ_FROM, SC_STATE_GET_MEM_OUTPUT_DATA,
36
                SC_STATE_SEND_OCTET, SC_STATE_WAIT_OCTET_SENT, SC_STATE_WORD_SENT);
37
 
38
        signal sc_state, next_sc_state: state_type;
39
        signal sc_current_address, next_sc_current_address: std_logic_vector(LA_MEM_ADDRESS_BITS-1 downto 0);
40
        signal sc_octet_id, next_sc_octet_id:std_logic_vector(LA_MEM_WORDLEN_OCTETS-1 downto 0);
41
        signal sc_word_bits, next_sc_word_bits: std_logic_vector(LA_MEM_WORDLEN_BITS-1 downto 0);
42
 
43
begin
44
 
45
        -- set up next value
46
   state_reg: process(clk, rst_l)
47
   begin
48
                if (rst_l='0') then
49
                        sc_state<=SC_STATE_IDLE;
50
                        sc_current_address<=(others => '0');
51
                        sc_word_bits<=(others => '0');
52
                        sc_octet_id<= (others => '0');
53
                elsif (rising_edge(clk)) then
54
                        if (baud_clk_posedge = '1') then
55
                                sc_state <= next_sc_state;
56
                                sc_current_address <= next_sc_current_address;
57
                                sc_word_bits <= next_sc_word_bits;
58
                                sc_octet_id <= next_sc_octet_id;
59
                        end if;
60
                end if;
61
        end process;
62
 
63
        -- state machine
64
   comb_logic: process(sc_state, sc_run, xmit_doneH,
65
                sc_current_address, sc_word_bits, sc_octet_id, mem_port_B_dout)
66
        begin
67
                -- implicit
68
                next_sc_state<=sc_state;
69
                ack_sc_run<='0';
70
                sc_done<='0';
71
                xmit_dataH<=(others => '0');
72
                xmitH<='0';
73
                mem_port_B_address<=sc_current_address;
74
                next_sc_current_address<=sc_current_address;
75
                next_sc_word_bits<=sc_word_bits;
76
                next_sc_octet_id<=sc_octet_id;
77
                case sc_state is
78
                        when SC_STATE_IDLE =>
79
                                if(sc_run = '1') then
80
                                        next_sc_state <= SC_STATE_ACK_SC_RUN;
81
                                        next_sc_current_address <= LA_MEM_LAST_ADDR_SLV;
82
                                else
83
                                        next_sc_state <= SC_STATE_IDLE;
84
                                end if;
85
                        when SC_STATE_ACK_SC_RUN =>
86
                                ack_sc_run <= '1';
87
                                next_sc_state <= SC_STATE_SET_MEMADDR_TO_READ_FROM;
88
                        when SC_STATE_SET_MEMADDR_TO_READ_FROM =>
89
                                mem_port_B_address <= sc_current_address;
90
                                -- next clock cycle we have memory dout of our read.
91
                                next_sc_state <= SC_STATE_GET_MEM_OUTPUT_DATA;
92
                        when SC_STATE_GET_MEM_OUTPUT_DATA =>
93
                                next_sc_word_bits <= mem_port_B_dout;
94
                                -- LSB first
95
                                next_sc_octet_id <= (others => '0');
96
                                next_sc_state <= SC_STATE_SEND_OCTET;
97
                        when SC_STATE_SEND_OCTET =>
98
                                xmit_dataH <= sc_word_bits(7 downto 0);
99
                                next_sc_word_bits <= x"00" & sc_word_bits(LA_MEM_WORDLEN_BITS-1 downto 8);
100
                                        -- shift_right(unsigned(sc_word_bits),8);
101
                                xmitH <= '1';
102
                                next_sc_octet_id <= std_logic_vector(to_unsigned(
103
                                        to_integer(unsigned(sc_octet_id))+1, LA_MEM_WORDLEN_OCTETS));
104
                                next_sc_state <= SC_STATE_WAIT_OCTET_SENT;
105
                        when SC_STATE_WAIT_OCTET_SENT =>
106
                                if(xmit_doneH = '1') then
107
                                        if(to_integer(unsigned(sc_octet_id)) < LA_MEM_WORDLEN_OCTETS) then
108
                                                next_sc_state <= SC_STATE_SEND_OCTET;
109
                                        else
110
                                                next_sc_state <= SC_STATE_WORD_SENT;
111
                                        end if;
112
                                else
113
                                        next_sc_state <= SC_STATE_WAIT_OCTET_SENT;
114
                                end if;
115
                        when SC_STATE_WORD_SENT =>
116
                                if(to_integer(unsigned(sc_current_address)) > LA_MEM_FIRST_ADDR) then
117
                                        next_sc_current_address <= std_logic_vector(to_unsigned(
118
                                                to_integer(unsigned(sc_current_address))-1, LA_MEM_ADDRESS_BITS));
119
                                        next_sc_state <= SC_STATE_SET_MEMADDR_TO_READ_FROM;
120
                                else
121
                                        -- done sending all captured data
122
                                        sc_done <= '1';
123
                                        next_sc_state <= SC_STATE_IDLE;
124
                                end if;
125
                        when others =>
126
                                -- this is forced by the vhdl compiler
127
                end case;
128
   end process;
129
 
130
end send_capture_of_verifla_arch;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.