signal read_strobe : std_logic;
signal interrupt : std_logic :='0';
signal interrupt_ack : std_logic;
signal reset : std_logic;
signal counter : std_logic_vector(7 downto 0);
signal HEX0 : std_logic_vector(3 downto 0);
signal HEX1 : std_logic_vector(3 downto 0);
signal HEX : std_logic_vector(3 downto 0);
signal sel : std_logic;
--
-------------------------------------------------------------------------
begin
processor: kcpsm3
port map( address => address,
instruction => instruction,
port_id => port_id,
write_strobe => write_strobe,
out_port => out_port,
read_strobe => read_strobe,
in_port => in_port,
interrupt => interrupt,
interrupt_ack => interrupt_ack,
reset => reset,
clk => clk);
program: int_test
port map( address => address,
instruction => instruction,
clk => clk);
-- Unused inputs on processor
in_port <= "00000000";
reset <= '0';
-- Adding the output registers to the processor
IO_registers: process(clk)
begin
if clk'event and clk='1' then
-- waveform register at address 02
if port_id(1)='1' and write_strobe='1' then
waveforms <= out_port;
end if;
-- Interrupt Counter register at address 04
if port_id(2)='1' and write_strobe='1' then
counter <= out_port;
end if;
-- sel port register at address 08
if port_id(3) = '1' and write_strobe = '1' then
sel <= out_port(0);
end if;
end if;
end process IO_registers;
-- Adding the interrupt input
-- Note that the initial value of interrupt (low) is
-- defined at signal declaration.
interrupt_control: process(clk)
begin
if clk'event and clk='1' then
if interrupt_ack='1' then
interrupt <= '0';
elsif interrupt_event='1' then
interrupt <= '1';
else
interrupt <= interrupt;
end if;
end if;
end process interrupt_control;
HEX0 <= counter(3 downto 0);
HEX1 <= counter(7 downto 4);
with HEX SELect
LED <= "0000110" when "0001", --1
"1011011" when "0010", --2
"1001111" when "0011", --3
"1100110" when "0100", --4
"1101101" when "0101", --5
"1111101" when "0110", --6
"0000111" when "0111", --7
"1111111" when "1000", --8
"1101111" when "1001", --9
"1110111" when "1010", --A
"1111100" when "1011", --b
"0111001" when "1100", --C
"1011110" when "1101", --d
"1111001" when "1110", --E
"1110001" when "1111", --F
"0111111" when others; --0
HEX <= HEX0 when sel = '0' else HEX1;
selp <= sel;
end Behavioral;
添加約束文件,約束文件內容如下。
NET "clk" LOC = "E12"|IOSTANDARD = LVCMOS33 ;
NET "selp" LOC = "AB19"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<6>" LOC = "AA19"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<5>" LOC = "AB21"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<4>" LOC = "AA21"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<3>" LOC = "V16"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<2>" LOC = "W16"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<1>" LOC = "V15"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<0>" LOC = "V14"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<0>" LOC ="R20"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<1>" LOC ="T19"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<2>" LOC ="U20"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<3>" LOC ="U19"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<4>" LOC ="V19"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<5>" LOC ="V20"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<6>" LOC ="Y22"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<7>" LOC ="W21"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
#PACE: Start of PACE Area Constraints
NET "interrupt_event" LOC = "T9"|IOSTANDARD = LVCMOS33|PULLUP ;
5. 綜合、布局布線。如圖12-31所示,在ISE中完成布局布線。
?
圖12-31 綜合、布局布線
6. 配置FPGA。用iMPACT配置FPGA。
7. 讀者可以在/CH12/kcpsm3_int_test中找到ISE工程文件,在/CH12/assembler中找到int_test.psm源文件。
12.8 小結
本章介紹了PicoBlaze微控制器,包括其基本結構、指令系統和開發工具,最后用一個簡單的實例介紹了PicoBlaze的開發流程。PicoBlaze具有精小、易用、靈活、高性能等優點,不會像很多MCU一樣停產,影響產品生命周期,可以方便地應用在Xilinx的FPGA中,特別適合應用于小型的控制系統中,用來實現狀態機控制,進行系統管理。
目前,FPGA已經廣泛地應用在游戲機產品、小型電機控制和醫療產品中,希望通過本章介紹,使其應用更加廣泛。
評論
查看更多