--////////////////////////////////////////////////////////////////////
|
--////////////////////////////////////////////////////////////////////
|
--// ////
|
--// ////
|
--// parse_price_wrapper.vhd ////
|
--// parse_price_wrapper.vhd ////
|
--// ////
|
--// ////
|
--// This file is part of the open_hitter opencores effort. ////
|
--// This file is part of the open_hitter opencores effort. ////
|
--// <http://www.opencores.org/cores/open_hitter/> ////
|
--// <http://www.opencores.org/cores/open_hitter/> ////
|
--// ////
|
--// ////
|
--// Module Description: ////
|
--// Module Description: ////
|
--// Simulation program (non-synthesizable) ////
|
--// Simulation program (non-synthesizable) ////
|
--// Single module development: parse_price.vhd ////
|
--// Single module development: parse_price.vhd ////
|
--// target env: ghdl <attrib required> ////
|
--// target env: ghdl <attrib required> ////
|
--// ////
|
--// ////
|
--// To Do: ////
|
--// To Do: ////
|
--// #LOTS ////
|
--// #LOTS ////
|
--// ////
|
--// ////
|
--// Author(s): ////
|
--// Author(s): ////
|
--// - Stephen Hawes ////
|
--// - Stephen Hawes ////
|
--// ////
|
--// ////
|
--////////////////////////////////////////////////////////////////////
|
--////////////////////////////////////////////////////////////////////
|
--// ////
|
--// ////
|
--// Copyright (C) 2015 Stephen Hawes and OPENCORES.ORG ////
|
--// Copyright (C) 2015 Stephen Hawes and OPENCORES.ORG ////
|
--// ////
|
--// ////
|
--// This source file may be used and distributed without ////
|
--// This source file may be used and distributed without ////
|
--// restriction provided that this copyright statement is not ////
|
--// restriction provided that this copyright statement is not ////
|
--// removed from the file and that any derivative work contains ////
|
--// removed from the file and that any derivative work contains ////
|
--// the original copyright notice and the associated disclaimer. ////
|
--// the original copyright notice and the associated disclaimer. ////
|
--// ////
|
--// ////
|
--// This source file is free software; you can redistribute it ////
|
--// This source file is free software; you can redistribute it ////
|
--// and/or modify it under the terms of the GNU Lesser General ////
|
--// and/or modify it under the terms of the GNU Lesser General ////
|
--// Public License as published by the Free Software Foundation; ////
|
--// Public License as published by the Free Software Foundation; ////
|
--// either version 2.1 of the License, or (at your option) any ////
|
--// either version 2.1 of the License, or (at your option) any ////
|
--// later version. ////
|
--// later version. ////
|
--// ////
|
--// ////
|
--// This source is distributed in the hope that it will be ////
|
--// This source is distributed in the hope that it will be ////
|
--// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
--// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
--// PURPOSE. See the GNU Lesser General Public License for more ////
|
--// PURPOSE. See the GNU Lesser General Public License for more ////
|
--// details. ////
|
--// details. ////
|
--// ////
|
--// ////
|
--// You should have received a copy of the GNU Lesser General ////
|
--// You should have received a copy of the GNU Lesser General ////
|
--// Public License along with this source; if not, download it ////
|
--// Public License along with this source; if not, download it ////
|
--// from <http://www.opencores.org/lgpl.shtml> ////
|
--// from <http://www.opencores.org/lgpl.shtml> ////
|
--// ////
|
--// ////
|
--////////////////////////////////////////////////////////////////////
|
--////////////////////////////////////////////////////////////////////
|
--//
|
--//
|
--// \$Id\$ TAKE OUT THE \'s and this comment in order to get this to work
|
--// \$Id\$ TAKE OUT THE \'s and this comment in order to get this to work
|
--//
|
--//
|
--// CVS Revision History
|
--// CVS Revision History
|
--//
|
--//
|
--// \$Log\$ TAKE OUT THE \'s and this comment in order to get this to work
|
--// \$Log\$ TAKE OUT THE \'s and this comment in order to get this to work
|
--//
|
--//
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use std.textio.all; -- Imports the standard textio package.
|
use std.textio.all; -- Imports the standard textio package.
|
-- use ieee.std_logic_textio.all;
|
-- use ieee.std_logic_textio.all;
|
|
|
entity parse_price_wrapper is
|
entity parse_price_wrapper is
|
end parse_price_wrapper;
|
end parse_price_wrapper;
|
|
|
architecture behaviour of parse_price_wrapper is
|
architecture behaviour of parse_price_wrapper is
|
component parse_price
|
component parse_price
|
port (
|
port (
|
|
RX_CLK: in std_logic;
|
in_byte: in std_logic_vector(7 downto 0);
|
in_byte: in std_logic_vector(7 downto 0);
|
byte_reset: in std_logic;
|
byte_reset: in std_logic;
|
byte_ready: in std_logic;
|
byte_ready: in std_logic;
|
price_ready: out std_logic;
|
price_ready: out std_logic;
|
-- pxdata: out price_packet
|
-- pxdata: out price_packet
|
px_type: out std_logic_vector(4 downto 0);
|
px_type: out std_logic_vector(4 downto 0);
|
buy_sell: out std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
buy_sell: out std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
px: out std_logic_vector(15 downto 0); -- price
|
px: out std_logic_vector(15 downto 0); -- price
|
qty: out std_logic_vector(15 downto 0); -- quantity
|
qty: out std_logic_vector(15 downto 0); -- quantity
|
sec: out std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
sec: out std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
id: out std_logic_vector(15 downto 0) -- unique/identifier/counter
|
id: out std_logic_vector(15 downto 0) -- unique/identifier/counter
|
);
|
);
|
end component;
|
end component;
|
for parse_price_0: parse_price use entity work.parse_price;
|
for parse_price_0: parse_price use entity work.parse_price;
|
|
signal RX_CLK: std_logic;
|
signal in_byte: std_logic_vector(7 downto 0);
|
signal in_byte: std_logic_vector(7 downto 0);
|
signal byte_reset: std_logic;
|
signal byte_reset: std_logic;
|
signal byte_ready: std_logic;
|
signal byte_ready: std_logic;
|
signal price_ready: std_logic;
|
signal price_ready: std_logic;
|
-- pxdata: price_packet
|
-- pxdata: price_packet
|
signal px_type: std_logic_vector(4 downto 0);
|
signal px_type: std_logic_vector(4 downto 0);
|
signal buy_sell: std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
signal buy_sell: std_logic_vector(2 downto 0); -- 111 buy, 000 sell
|
signal px: std_logic_vector(15 downto 0); -- price
|
signal px: std_logic_vector(15 downto 0); -- price
|
signal qty: std_logic_vector(15 downto 0); -- quantity
|
signal qty: std_logic_vector(15 downto 0); -- quantity
|
signal sec: std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
signal sec: std_logic_vector(55 downto 0); -- 7x 8bits securities identifier
|
signal id: std_logic_vector(15 downto 0); -- unique/identifier/counter
|
signal id: std_logic_vector(15 downto 0); -- unique/identifier/counter
|
begin
|
begin
|
parse_price_0: parse_price port map (
|
parse_price_0: parse_price port map (
|
|
RX_CLK => RX_CLK,
|
in_byte => in_byte,
|
in_byte => in_byte,
|
byte_reset => byte_reset,
|
byte_reset => byte_reset,
|
byte_ready => byte_ready,
|
byte_ready => byte_ready,
|
price_ready => price_ready,
|
price_ready => price_ready,
|
-- price_packet
|
-- price_packet
|
px_type => px_type,
|
px_type => px_type,
|
buy_sell => buy_sell,
|
buy_sell => buy_sell,
|
px => px,
|
px => px,
|
qty => qty,
|
qty => qty,
|
sec => sec,
|
sec => sec,
|
id => id
|
id => id
|
);
|
);
|
process
|
process
|
variable l : line;
|
variable l : line;
|
-- WWHHAATTSSEECC
|
-- WWHHAATTSSEECC
|
constant pkt : std_logic_vector(103 downto 0) := X"081234567857484154534543C0";
|
constant pkt : std_logic_vector(111 downto 0) := X"081234567857484154534543C078";
|
variable pos : integer;
|
variable pos : integer;
|
variable offset : integer;
|
variable offset : integer;
|
variable eoffset : integer;
|
variable eoffset : integer;
|
begin
|
begin
|
write (l, String'("Exercising parse_price"));
|
write (l, String'("Exercising parse_price"));
|
writeline (output, l);
|
writeline (output, l);
|
|
|
|
byte_reset <= '1';
|
byte_ready <= '0';
|
byte_ready <= '0';
|
|
RX_CLK <= '0';
|
wait for 1 ns;
|
wait for 1 ns;
|
byte_reset <= '1';
|
RX_CLK <= '1';
|
byte_ready <= '1';
|
|
wait for 1 ns;
|
wait for 1 ns;
|
byte_ready <= '0';
|
RX_CLK <= '0';
|
wait for 1 ns;
|
wait for 1 ns;
|
byte_reset <= '0';
|
|
|
|
for pos in 12 downto 0 loop
|
for pos in 13 downto 0 loop
|
in_byte <= pkt(8*pos+7 downto 8*pos);
|
in_byte <= pkt(8*pos+7 downto 8*pos);
|
byte_ready <= '1';
|
byte_ready <= '1';
|
|
byte_reset <= '0';
|
|
RX_CLK <= '1';
|
wait for 1 ns;
|
wait for 1 ns;
|
|
|
for i in in_byte'range loop
|
for i in in_byte'range loop
|
write(l, std_logic'image(in_byte(i)) );
|
write(l, std_logic'image(in_byte(i)) );
|
end loop;
|
end loop;
|
|
|
write(l, String'(" px_type:"));
|
write(l, String'(" px_type:"));
|
for i in px_type'range loop
|
for i in px_type'range loop
|
write(l, std_logic'image(px_type(i)) );
|
write(l, std_logic'image(px_type(i)) );
|
end loop;
|
end loop;
|
|
|
write(l, String'(" buy_sell:"));
|
write(l, String'(" buy_sell:"));
|
for i in buy_sell'range loop
|
for i in buy_sell'range loop
|
write(l, std_logic'image(buy_sell(i)) );
|
write(l, std_logic'image(buy_sell(i)) );
|
end loop;
|
end loop;
|
|
|
write(l, String'(" px:"));
|
write(l, String'(" px:"));
|
for i in px'range loop
|
for i in px'range loop
|
write(l, std_logic'image(px(i)) );
|
write(l, std_logic'image(px(i)) );
|
end loop;
|
end loop;
|
|
|
write(l, String'(" qty:"));
|
write(l, String'(" qty:"));
|
for i in qty'range loop
|
for i in qty'range loop
|
write(l, std_logic'image(qty(i)) );
|
write(l, std_logic'image(qty(i)) );
|
end loop;
|
end loop;
|
|
|
write(l, String'(" sec:"));
|
write(l, String'(" sec:"));
|
for i in sec'range loop
|
for i in sec'range loop
|
write(l, std_logic'image(sec(i)) );
|
write(l, std_logic'image(sec(i)) );
|
end loop;
|
end loop;
|
|
|
write(l, String'(" id:"));
|
write(l, String'(" id:"));
|
for i in id'range loop
|
for i in id'range loop
|
write(l, std_logic'image(id(i)) );
|
write(l, std_logic'image(id(i)) );
|
end loop;
|
end loop;
|
|
|
writeline(output, l);
|
writeline(output, l);
|
|
|
byte_ready <= '0';
|
RX_CLK <= '0';
|
wait for 1 ns;
|
wait for 1 ns;
|
end loop;
|
end loop;
|
|
|
|
|
write (l, String'("Done parse_price"));
|
write (l, String'("Done parse_price"));
|
writeline (output, l);
|
writeline (output, l);
|
|
-- 081234 5678 574841545345 43C0
|
if (px_type = B"01000") and (buy_sell = B"000") and (px = B"00000000_00001000")
|
if (px_type = B"00001") and (buy_sell = B"000") and (px = B"00010010_00110100") -- 081234
|
and (qty = B"00110100_00110100")
|
and (qty = B"01010110_01111000") -- 5678
|
and (sec = B"01001000_01000001_01000001_01010100_01010100_01010011_01010011")
|
and (sec = B"01010111_01001000_01000001_01010100_01010011_01000101_01000011") -- 57484154534543
|
and (id = B"01000011_01000011")
|
and (id = B"11000000_01111000") -- C078
|
then
|
then
|
write (l, String'("... and Price is OK."));
|
write (l, String'("... and Price is OK."));
|
writeline (output, l);
|
writeline (output, l);
|
|
else
|
|
write (l, String'("... and price check failed."));
|
|
writeline (output, l);
|
end if;
|
end if;
|
|
|
wait;
|
wait;
|
end process;
|
end process;
|
end behaviour;
|
end behaviour;
|
|
|