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

Subversion Repositories openverifla

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 46 laurentiud
/*
2
file: send_capture_of_verifla.v
3
license: GNU GPL
4
Revision history
5
revision date: 20180808-1540
6
- include baud_clk_posedge
7
 
8
revision date: 2007/Jul/4; author: Laurentiu DUCA
9
- v01
10
*/
11
 
12
 
13
//`timescale 1ns/1ps
14
module send_capture_of_verifla(clk, rst_l, baud_clk_posedge,
15
        sc_run, ack_sc_run, sc_done,
16
        mem_port_B_address, mem_port_B_dout,
17
        xmit_doneH, xmitH, xmit_dataH);
18
 
19
`include "common_internal_verifla.v"
20
 
21
// SC_states
22
parameter
23
        SC_STATES_BITS=4,
24
        SC_STATE_IDLE=0,
25
        SC_STATE_ACK_SC_RUN=1,
26
        SC_STATE_SET_MEMADDR_TO_READ_FROM=2,
27
        SC_STATE_GET_MEM_OUTPUT_DATA=3,
28
        SC_STATE_SEND_OCTET=4,
29
        SC_STATE_WAIT_OCTET_SENT=5,
30
        SC_STATE_WORD_SENT=6;
31
 
32
// input
33
input clk, rst_l;
34
input baud_clk_posedge;
35
input sc_run;
36
input [LA_MEM_WORDLEN_BITS-1:0] mem_port_B_dout;
37
input xmit_doneH;
38
// output
39
output [LA_MEM_ADDRESS_BITS-1:0] mem_port_B_address;
40
output xmitH;
41
output [7:0] xmit_dataH;
42
output ack_sc_run, sc_done;
43
reg [LA_MEM_ADDRESS_BITS-1:0] mem_port_B_address;
44
reg xmitH;
45
reg [7:0] xmit_dataH;
46
reg ack_sc_run, sc_done;
47
// local
48
reg [SC_STATES_BITS-1:0] sc_state, next_sc_state;
49
reg [LA_MEM_ADDRESS_BITS-1:0] sc_current_address, next_sc_current_address;
50
reg [LA_MEM_WORDLEN_OCTETS-1:0] sc_octet_id, next_sc_octet_id;
51
reg [LA_MEM_WORDLEN_BITS-1:0] sc_word_bits, next_sc_word_bits;
52
 
53
// set up next value
54
always @(posedge clk or negedge rst_l)
55
begin
56
        if(~rst_l)
57
        begin
58
                sc_state=SC_STATE_IDLE;
59
                sc_current_address=0;
60
                sc_word_bits=0;
61
                sc_octet_id=0;
62
        end
63
        else
64
                if (baud_clk_posedge)
65
                begin
66
                        sc_state=next_sc_state;
67
                        sc_current_address=next_sc_current_address;
68
                        sc_word_bits=next_sc_word_bits;
69
                        sc_octet_id=next_sc_octet_id;
70
                end
71
end
72
 
73
// state machine
74
always @(sc_state or sc_run or xmit_doneH
75
        // not important but xilinx warnings.
76
        or sc_current_address or mem_port_B_dout or sc_word_bits or sc_octet_id)
77
begin
78
        // implicitly
79
        next_sc_state=sc_state;
80
        ack_sc_run=0;
81
        sc_done=0;
82
        xmit_dataH=0;
83
        xmitH=0;
84
        mem_port_B_address=sc_current_address;
85
        next_sc_current_address=sc_current_address;
86
        next_sc_word_bits=sc_word_bits;
87
        next_sc_octet_id=sc_octet_id;
88
 
89
        // state dependent
90
        case(sc_state)
91
        SC_STATE_IDLE:
92
        begin
93
                if(sc_run)
94
                begin
95
                        next_sc_state = SC_STATE_ACK_SC_RUN;
96
                        next_sc_current_address=LA_MEM_LAST_ADDR;
97
                end
98
                else
99
                        next_sc_state = SC_STATE_IDLE;
100
        end
101
        SC_STATE_ACK_SC_RUN:
102
        begin
103
                ack_sc_run=1;
104
                next_sc_state = SC_STATE_SET_MEMADDR_TO_READ_FROM;
105
        end
106
        SC_STATE_SET_MEMADDR_TO_READ_FROM:
107
        begin
108
                mem_port_B_address=sc_current_address;
109
                // next clock cycle we have memory dout of our read.
110
                next_sc_state = SC_STATE_GET_MEM_OUTPUT_DATA;
111
        end
112
        SC_STATE_GET_MEM_OUTPUT_DATA:
113
        begin
114
                next_sc_word_bits=mem_port_B_dout;
115
                // LSB first
116
                next_sc_octet_id=0;
117
                next_sc_state = SC_STATE_SEND_OCTET;
118
        end
119
        SC_STATE_SEND_OCTET:
120
        begin
121
                xmit_dataH=sc_word_bits[7:0];
122
                next_sc_word_bits={8'd0, sc_word_bits[LA_MEM_WORDLEN_BITS-1:8]}; //sc_word_bits>>8;
123
                xmitH=1;
124
                next_sc_octet_id=sc_octet_id+1;
125
                next_sc_state = SC_STATE_WAIT_OCTET_SENT;
126
        end
127
        SC_STATE_WAIT_OCTET_SENT:
128
        begin
129
                if(xmit_doneH)
130
                begin
131
                        if(sc_octet_id < LA_MEM_WORDLEN_OCTETS)
132
                                next_sc_state = SC_STATE_SEND_OCTET;
133
                        else
134
                                next_sc_state = SC_STATE_WORD_SENT;
135
                end
136
                else
137
                        next_sc_state = SC_STATE_WAIT_OCTET_SENT;
138
        end
139
        SC_STATE_WORD_SENT:
140
        begin
141
                if(sc_current_address > LA_MEM_FIRST_ADDR)
142
                begin
143
                        next_sc_current_address=sc_current_address-1;
144
                        next_sc_state = SC_STATE_SET_MEMADDR_TO_READ_FROM;
145
                end
146
                else
147
                begin
148
                        // done sending all captured data
149
                        sc_done = 1;
150
                        next_sc_state = SC_STATE_IDLE;
151
                end
152
        end
153
        default: // should never get here
154
        begin
155
                next_sc_state=4'bxxxx;
156
                sc_done=1'bx;
157
                xmit_dataH=1'bx;
158
                xmitH=1'bx;
159
                mem_port_B_address={LA_MEM_ADDRESS_BITS{1'bx}};
160
                next_sc_current_address={LA_MEM_ADDRESS_BITS{1'bx}};
161
                next_sc_word_bits={LA_MEM_WORDLEN_BITS{1'bx}};
162
                next_sc_octet_id={LA_MEM_WORDLEN_OCTETS{1'bx}};
163
        end
164
        endcase
165
end
166
 
167
endmodule

powered by: WebSVN 2.1.0

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