Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

programming fpga by JTAG WITH VHDL CODE

Status
Not open for further replies.

gaffarnazari@yahoo.com

Member level 1
Member level 1
Joined
Dec 26, 2012
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,538
HI TO ALL.
in the first:
I write this vhdl code for fpga with xin=10mhz

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
 
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
 
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
 
entity spi1 is
    Port ( clk : in  STD_LOGIC; --100 Mhz
            SO :out std_logic;  --lsfr out
              rst_n : in std_logic;
             Go : inout std_logic ;
              SE_N : out std_logic := '1';
              SDATA : out std_logic := '0';
              SCLK : INout std_logic;
              pn :out std_logic := '1';
              led:out std_logic_vector(6 downto 0):="0000000"
                       );
end spi1;
 
architecture Behavioral of nikkar_spi1 is
 
type write_vec is array (9 downto 1) of std_logic_vector(21 downto 0) ;
signal wire_send_spi:write_vec;
signal reg_send_spi : std_logic_vector(21 downto 0) := (others => '0');
signal reg_cnt_data : integer range 0 to 31 := 21;
type type_sm_send_spi is (IDLE,RCV_GO,SEND,ENDED,waiting);
signal sm_send_spi : type_sm_send_spi;
signal dataNum :integer range 1 to 9:=1;
signal sendStart  :std_logic := '1';
signal data:integer range 1 to 3;
signal sendEnd :std_logic := '1';
signal count1 : integer range 1 to 10000000:=1;    ---delay 1s
 
begin
pn<='1';
process(clk,rst_n)
 
begin
if(rst_n = '0') then
 
sendStart<='0';
    elsif (clk' event and clk='0') then
 
 
case data is
 
    when 1 =>
sendStart<='1';
        wire_send_spi(1)<="0000110000000010000000";  
        wire_send_spi(2)<="0000000000000101000001";  
        wire_send_spi(3)<="0000000000000000110010"; 
        wire_send_spi(4)<="0000000000000000000011";  
        wire_send_spi(5)<="0000001111110100100100";   
        wire_send_spi(6)<="0000000000000000000101"; 
        wire_send_spi(7)<="0000000000000000000110";
        wire_send_spi(8)<="0000000000010100000111";  
        wire_send_spi(9)<="0000000000001100101000";  
        if(sendEnd='1')then
        sendStart<='0';
        end if;
when 2 =>
        sendStart<='1';
                    wire_send_spi(1)<="0000110000000000000000"; 
                    wire_send_spi(2)<="0000000000001010010001";  
        wire_send_spi(3)<="0000000000000000010010"; 
        wire_send_spi(4)<="0000000000000000000011"; 
        wire_send_spi(5)<="0000010000000001000100";   
        wire_send_spi(6)<="0000000000000000000101";   
        wire_send_spi(7)<="0000000000000000000110";    
        wire_send_spi(8)<="0000000000010100000111";    
        wire_send_spi(9)<="0000000000000000001000";    
        if(sendEnd='1')then
            sendStart<='0';
            
 end if;
when 3 =>
    sendStart<='1';
              wire_send_spi(1)<="0000110000000000000000";
              wire_send_spi(2)<="0000000000001010010001";   
     wire_send_spi(3)<="0000000000000000010010";  
     wire_send_spi(4)<="0000000000000000000011"; 
    wire_send_spi(5)<="0000010000001101100100";   
    wire_send_spi(6)<="0000000000000000000101";       
             wire_send_spi(7)<="0000000000000000000110";
    wire_send_spi(8)<="0000000000010100000111";    
           wire_send_spi(9)<="0000000000000000001000";    
        if(sendEnd='1')then
            sendStart<='0';
    end if;
when others =>  
    end case;
 
end if; 
 
end process;
 
 
SCLK<=clk;
    
 
process(SCLK,rst_n) is
begin
 
if (rst_n = '0') then
    SE_N <= '1';
    SDATA <='0';
    sm_send_spi<=IDLE;
    sendEnd<='0';
elsif(SCLK' event and SCLK='0')then
 
    case sm_send_spi is
----------------------------------------------------------------------------------------------
    when IDLE =>
        
        SE_N <= '1';
        SDATA <= '0';
        sendEnd<='0';
        dataNum<=1;
        if (sendStart ='1') then 
Go<='0';            
            reg_send_spi <= wire_send_spi(dataNum);
            sm_send_spi <= rcv_go;
        
        end if;
---------------------------------------------------------------------------------------     
    when RCV_GO =>
 
        SE_N <= '0';
        reg_cnt_data<=21;
        SDATA <= reg_send_spi(21);
        --------------
        
        sm_send_spi <= SEND;    
        
--------------------------------------------------------------------------------------------------------        
    when SEND =>
       led(6) <='0';
if (reg_cnt_data > 0) then
            SDATA <= reg_send_spi(reg_cnt_data-1);
            reg_cnt_data <= reg_cnt_data - 1;
        else
            SE_N <= '1';
            dataNum<=dataNum+1;
            sm_send_spi <= ENDED;   
        end if;
-------------------------------------------------------------------------------     
    when ENDED =>
 
        if(dataNum=10)then
            sm_send_spi <=waiting;
            Go<='1';
            sendEnd<='1';
        else
            reg_send_spi <= wire_send_spi(dataNum);
            sm_send_spi <= RCV_GO;      
    end if;
-----   ------------------------------------------------------------------------------
    when waiting => 
 
           led(6) <='1';
if(count1=10000000)then
    sm_send_spi <=IDLE;
if(data=4)then
        data<=1;
        else
            data <=data+1;
            
            
    end if;     
    count1 <=1;
else
    count1 <=count1+1;
    led (5 downto 0) <= conv_std_logic_vector(data,6);
    end if;
    
    end case;
end if; 
    
end process;
-------------------------------------------------


and my problem :
WHEN I simulated this code the led's dont turn on in type of waiting
because I WRITE CODE FOR 1s delay but on the my board I see only signal data=1
why I cant see data=2 and 3 when I PROGRAMMING code on fpga board and how I CAN SEE IN THIS case on led's?
for 1S delay: COUNT1=10000000 WITH XIN OF FPGA ON THE BOARD IS EQUAL=10MHZ
THANK YOU
 
Last edited by a moderator:

HI TO ALL.
in the first:
I write this vhdl code for fpga with xin=10mhz

and my problem :
WHEN I simulated this code the led's dont turn on in type of waiting
because I WRITE CODE FOR 1s delay but on the my board I see only signal data=1
why I cant see data=2 and 3 when I PROGRAMMING code on fpga board and how I CAN SEE IN THIS case on led's?
for 1S delay: COUNT1=10000000 WITH XIN OF FPGA ON THE BOARD IS EQUAL=10MHZ
THANK YOU

Your question is unclear, where is xin in your code? Is that a signal on the schematic is it the same as the clk port?

Are you having problems with simulation or on hardware after implementing the design? You mention both simulated and programming code on the board.

Are you sure you have the XIN pin specified for clk in your constraints?

The following looks wrong, I might be mistaken, but I don't think you can use a value outside the range specified.
Code:
signal data:integer range 1 to 3;
-- You're comparing data with 4, which is outside the range in the declaration?
    if(data=4)then
        data<=1;
    else
        data <=data+1;
    end if;
 

--excuse me data is equal=3 I MISTAKE THERE.
my problem is I cant see type of when( 2 and 3) on ouput on hardware(fpga board) I only see type of when 1
and other problem I assign led<=conv_std_logic_vector(data,6) but I CANT see it on out put on board(by led's) ( my delay is equal 1s)
how can I SEE my data on led's on the board?(what is that code?)
thank you
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top