реклама на сайте
подробности

 
 
 
Reply to this topicStart new topic
> передача параметра
sergey sva
сообщение Nov 4 2013, 18:47
Сообщение #1


Гуру
******

Группа: Свой
Сообщений: 2 546
Регистрация: 23-05-07
Из: Самарская область Сызрань
Пользователь №: 27 923



Подскажите как сделать передачу параметра из verilog модуля в vhdl?
Код
entity crc_modbus is
entity ucrc_par is    
  generic (
    POLYNOMIAL: std_logic_vector;      
    INIT_VALUE: std_logic_vector;
    DATA_WIDTH: integer range 2 to 256;
    SYNC_RESET: integer range 0 to 1);  -- use sync./async reset
  port (
    clk_i: in std_logic;                -- clock
    rst_i: in std_logic;                -- init CRC
    clken_i: in std_logic;              -- clock enable
    data_i: in std_logic_vector(DATA_WIDTH - 1 downto 0); -- data input
    match_o: out std_logic;             -- CRC match flag
    crc_o: out std_logic_vector(POLYNOMIAL'length - 1 downto 0)); -- CRC output
end ucrc_par;
....
....
....


Verilog Как передать параметры которые в generic?
Код
crc_modbus crccoun(.clk_i(CLCK),.rst_i(initcrc),.clken_i(clckcrcin),.data_i(serindata[countdatacrc]),.match_o(matchflag),.crc_o(crcresultreceive));



Вроде сообразил ) Правильно?
Код
ucrc_par#(.POLYNOMIAL(40961),.INIT_VALUE(65535),.DATA_WIDTH(8),.SYNC_RESET(0))  
CrcReceiveData( .clk_i(CLCK),.rst_i(initcrc),.clken_i(clckcrcin),.data_i(serindata[countdatacrc]),.match_o(matchflag),.crc_o(crcresultreceive));


Только все равно ошибка вылетает при синтезе(
Цитата
ERROR:Xst - Xst_HdlType::GetArrayRightStatic : array is not static : array unsigned [_n0003 downto _n0003] of array unsigned [7 downto 0] of bit.
ERROR:Xst:2683 - Unexpected error found while building hierarchy.

Может в коде проблема давно уже с vhdl не разбирался(
CODE
----------------------------------------------------------------------
---- ----
---- Ultimate CRC. ----
---- ----
---- This file is part of the ultimate CRC projectt ----
---- http://www.opencores.org/cores/ultimate_crc/ ----
---- ----
---- Description ----
---- CRC generator/checker, parallel implementation. ----
---- ----
---- ----
---- To Do: ----
---- - ----
---- ----
---- Author(s): ----
---- - Geir Drange, gedra@opencores.org ----
---- ----
----------------------------------------------------------------------
---- ----
---- Copyright © 2005 Authors and OPENCORES.ORG ----
---- ----
---- This source file may be used and distributed without ----
---- restriction provided that this copyright statement is not ----
---- removed from the file and that any derivative work contains ----
---- the original copyright notice and the associated disclaimer. ----
---- ----
---- This source file is free software; you can redistribute it ----
---- and/or modify it under the terms of the GNU General ----
---- Public License as published by the Free Software Foundation; ----
---- either version 2.0 of the License, or (at your option) any ----
---- later version. ----
---- ----
---- This source is distributed in the hope that it will be ----
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
---- PURPOSE. See the GNU General Public License for more details.----
---- ----
---- You should have received a copy of the GNU General ----
---- Public License along with this source; if not, download it ----
---- from http://www.gnu.org/licenses/gpl.txt ----
---- ----
----------------------------------------------------------------------
--
-- CVS Revision History
--
-- $Log: ucrc_par.vhd,v $
-- Revision 1.1 2005/05/09 15:58:38 gedra
-- Parallel implementation
--
--
--

library ieee;
use ieee.std_logic_1164.all;

entity ucrc_par is
generic (
POLYNOMIAL: std_logic_vector;
INIT_VALUE: std_logic_vector;
DATA_WIDTH: integer range 2 to 256;
SYNC_RESET: integer range 0 to 1); -- use sync./async reset
port (
clk_i: in std_logic; -- clock
rst_i: in std_logic; -- init CRC
clken_i: in std_logic; -- clock enable
data_i: in std_logic_vector(DATA_WIDTH - 1 downto 0); -- data input
match_o: out std_logic; -- CRC match flag
crc_o: out std_logic_vector(POLYNOMIAL'length - 1 downto 0)); -- CRC output
end ucrc_par;

architecture rtl of ucrc_par is

constant msb : integer := POLYNOMIAL'length - 1;
constant init_msb : integer := INIT_VALUE'length - 1;
constant p : std_logic_vector(msb downto 0) := POLYNOMIAL;
constant dw : integer := DATA_WIDTH;
constant pw : integer := POLYNOMIAL'length;
type fb_array is array (dw downto 1) of std_logic_vector(msb downto 0);
type dmsb_array is array (dw downto 1) of std_logic_vector(msb downto 1);
signal crca: fb_array;
signal da, ma : dmsb_array;
signal crc, zero: std_logic_vector(msb downto 0);
signal arst, srst: std_logic;

begin

-- Parameter checking: Invalid generics will abort simulation/synthesis
PCHK1: if msb /= init_msb generate
process
begin
report "POLYNOMIAL and INIT_VALUE vectors must be equal length!"
severity failure;
wait;
end process;
end generate PCHK1;

PCHK2: if (msb < 3) or (msb > 31) generate
process
begin
report "POLYNOMIAL must be of order 4 to 32!"
severity failure;
wait;
end process;
end generate PCHK2;

PCHK3: if p(0) /= '1' generate -- LSB must be 1
process
begin
report "POLYNOMIAL must have lsb set to 1!"
severity failure;
wait;
end process;
end generate PCHK3;

-- Generate vector of each data bit
CA: for i in 1 to dw generate -- data bits
DAT: for j in 1 to msb generate
da(i)(j) <= data_i(i - 1);
end generate DAT;
end generate CA;

-- Generate vector of each CRC MSB
MS0: for i in 1 to msb generate
ma(1)(i) <= crc(msb);
end generate MS0;
MSP: for i in 2 to dw generate
MSU: for j in 1 to msb generate
ma(i)(j) <= crca(i - 1)(msb);
end generate MSU;
end generate MSP;

-- Generate feedback matrix
crca(1)(0) <= da(1)(1) xor crc(msb);
crca(1)(msb downto 1) <= crc(msb - 1 downto 0) xor ((da(1) xor ma(1)) and p(msb downto 1));
FB: for i in 2 to dw generate
crca(i)(0) <= da(i)(1) xor crca(i - 1)(msb);
crca(i)(msb downto 1) <= crca(i - 1)(msb - 1 downto 0) xor
((da(i) xor ma(i)) and p(msb downto 1));
end generate FB;

-- Reset signal
SR: if SYNC_RESET = 1 generate
srst <= rst_i;
arst <= '0';
end generate SR;
AR: if SYNC_RESET = 0 generate
srst <= '0';
arst <= rst_i;
end generate AR;

-- CRC process
crc_o <= crc;
zero <= (others => '0');

CRCP: process (clk_i, arst)
begin
if arst = '1' then -- async. reset
crc <= INIT_VALUE;
match_o <= '0';
elsif rising_edge(clk_i) then
if srst = '1' then -- sync. reset
crc <= INIT_VALUE;
match_o <= '0';
elsif clken_i = '1' then
crc <= crca(dw);
if crca(dw) = zero then
match_o <= '1';
else
match_o <= '0';
end if;
end if;
end if;
end process;

end rtl;
Go to the top of the page
 
+Quote Post
Kuzmi4
сообщение Nov 4 2013, 22:01
Сообщение #2


Гуру
******

Группа: Свой
Сообщений: 3 304
Регистрация: 13-02-07
Из: 55°55′5″ 37°52′16″
Пользователь №: 25 329



2 sergey sva
я так понял ругается на вот это:
Код
    POLYNOMIAL: std_logic_vector;      
    INIT_VALUE: std_logic_vector;

Размерности не статически заданы - вот и падает оно. Ф-ция, судя по названию GetArrayRightStatic, только для статических std_logic_vector-ов.
Задайте фиксированную длинну std_logic_vector-у, если дизайн позволяет конечно.
Go to the top of the page
 
+Quote Post
sergey sva
сообщение Nov 7 2013, 10:13
Сообщение #3


Гуру
******

Группа: Свой
Сообщений: 2 546
Регистрация: 23-05-07
Из: Самарская область Сызрань
Пользователь №: 27 923



Размер задал:
POLYNOMIAL: std_logic_vector(15 downto 0);
INIT_VALUE: std_logic_vector(15 downto 0);
ошибка
ERROR:Xst - Xst_HdlType::GetArrayRightStatic : array is not static : array unsigned [_n0003 downto _n0003] of array unsigned [7 downto 0] of bit.
ERROR:Xst:2683 - Unexpected error found while building hierarchy.

модуль описан так:
Цитата
reg[7:0] countdatacrc = 0;
wire[15:0] crcresultreceive;
reg initcrc;
reg clckcrcin;
reg matchflag;
ucrc_par#(.POLYNOMIAL(40961),.INIT_VALUE(65535),.DATA_WIDTH(8),.SYNC_RESET(0))
CrcReceiveData( .clk_i(CLCK),.rst_i(initcrc),.clken_i(clckcrcin),.data_i(serindata[countdatacrc]
),.match_o(matchflag),.crc_o(crcresultreceive));
Go to the top of the page
 
+Quote Post
yoggy
сообщение Dec 6 2013, 09:56
Сообщение #4





Группа: Участник
Сообщений: 11
Регистрация: 12-06-13
Из: Ростов
Пользователь №: 77 141



Разве в поле generic можно задать значение из верхнего уровня? В моем понимании - это еще одно представление констант. Поэтому задаваю сразу там же:

Код
   generic (
      POLYNOMIAL : std_logic_vector := X"04C11DB7";
      INIT_VALUE : std_logic_vector := X"00000000";
      DATA_WIDTH : integer range 2 to 256 := 8;
      SYNC_RESET : integer range 0 to 1 := 1 );  -- use sync./async reset


Другое дело, что у меня не получается эту корку выдавать правильные результаты. Правильные относительно спецификации.

Цитата
Name : CRC 32
Width : 32
Poly : 04C11DB7
Init : FFFFFFFF
RefIn : True
RefOut : True
XorOut : FFFFFFFF
Check : CBF43926
Go to the top of the page
 
+Quote Post
_Anatoliy
сообщение Dec 6 2013, 10:49
Сообщение #5


Утомлённый солнцем
******

Группа: Свой
Сообщений: 2 646
Регистрация: 15-07-06
Из: г.Донецк ДНР
Пользователь №: 18 832



Цитата(yoggy @ Dec 6 2013, 11:56) *
Поэтому задаваю сразу там же:

А если у Вас в проекте 10 таких модулей с разными параметрами?Будете держать на каждый модуль свой исходник? wacko.gif
Go to the top of the page
 
+Quote Post
yoggy
сообщение Dec 6 2013, 11:54
Сообщение #6





Группа: Участник
Сообщений: 11
Регистрация: 12-06-13
Из: Ростов
Пользователь №: 77 141



Цитата(_Anatoliy @ Dec 6 2013, 14:49) *
А если у Вас в проекте 10 таких модулей с разными параметрами?

Сейчас у меня такой задачи нет, поэтому для меня это самое оптимальное решение. Но суть понял, как решать в VHDL не знаю.
На verilog-e я такие вещи описываю через порты, а при сборке всех вместе, просто вписываю туда параметры из верхнего уровня.
..
Ну вот, пока писал ответ, решил нагуглить по теме.
В исходниках по ссылке вроде все понятно описано. Может ошибаюсь, в VHDL уже давно не разбирался sm.gif
http://vhdlguru.blogspot.ru/2010/03/generi...ruction-of.html

offtop: задаваю задаю
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 19th July 2025 - 13:02
Рейтинг@Mail.ru


Страница сгенерированна за 0.01422 секунд с 7
ELECTRONIX ©2004-2016