Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a916271e1 | ||
|
|
86a615148a | ||
|
|
8e74022cc6 | ||
|
|
3656fa9f90 | ||
|
|
b80e089211 | ||
|
|
b992b5cdd2 | ||
|
|
93f7eea2fe | ||
|
|
5ec9d4c9b8 | ||
|
|
a9fe0df1f2 | ||
|
|
14ad651f01 | ||
|
|
95b1b3d0ca | ||
|
|
67e19280dd |
No files matched your search
@@ -26,11 +26,43 @@ entity add is
|
||||
end entity add;
|
||||
|
||||
architecture rtl of add is
|
||||
|
||||
component float_add is -- #
|
||||
port ( -- #
|
||||
A : in std_logic_vector( 31 downto 0 ); -- #
|
||||
B : in std_logic_vector( 31 downto 0 ); -- #
|
||||
clk : in std_logic; -- #
|
||||
reset : in std_logic; -- #
|
||||
start : in std_logic; -- #
|
||||
done : out std_logic; -- #
|
||||
sum : out std_logic_vector( 31 downto 0 ) -- #
|
||||
); -- #
|
||||
end component float_add; -- #
|
||||
|
||||
signal current_task_state : work.task.State;
|
||||
signal next_task_state : work.task.State;
|
||||
signal index : integer range 0 to work.task.STREAM_LEN;
|
||||
|
||||
type AddState is ( ADD_IDLE, ADD_WAIT_DONE, ADD_WRITE, ADD_FINISH ); -- #
|
||||
signal current_add_state : AddState; -- #
|
||||
|
||||
signal add_start : std_logic; -- #
|
||||
signal add_done : std_logic; -- #
|
||||
signal add_sum : std_logic_vector( 31 downto 0 ); -- #
|
||||
|
||||
begin
|
||||
|
||||
float_add_inst : float_add -- #
|
||||
port map ( -- #
|
||||
A => signal_a_readdata, -- #
|
||||
B => signal_b_readdata, -- #
|
||||
clk => clk, -- #
|
||||
reset => reset, -- #
|
||||
start => add_start, -- #
|
||||
done => add_done, -- #
|
||||
sum => add_sum -- #
|
||||
); -- #
|
||||
|
||||
task_state_transitions : process ( current_task_state, task_start, index ) is
|
||||
begin
|
||||
next_task_state <= current_task_state;
|
||||
@@ -54,24 +86,73 @@ begin
|
||||
begin
|
||||
if ( reset = '1' ) then
|
||||
current_task_state <= work.task.TASK_IDLE;
|
||||
index <= 0;
|
||||
current_add_state <= ADD_IDLE; -- #
|
||||
index <= 0;
|
||||
signal_a_read <= '0'; -- #
|
||||
signal_b_read <= '0'; -- #
|
||||
signal_write <= '0'; -- #
|
||||
signal_writedata <= ( others => '0' ); -- #
|
||||
add_start <= '0'; -- #
|
||||
elsif ( rising_edge( clk ) ) then
|
||||
current_task_state <= next_task_state;
|
||||
case next_task_state is
|
||||
when work.task.TASK_IDLE =>
|
||||
index <= 0;
|
||||
signal_write <= '0';
|
||||
when work.task.TASK_RUNNING =>
|
||||
index <= index + 1;
|
||||
signal_write <= '1';
|
||||
signal_writedata <= ( others => '0' );
|
||||
when work.task.TASK_DONE =>
|
||||
index <= 0;
|
||||
signal_write <= '0';
|
||||
|
||||
signal_a_read <= '0'; -- #
|
||||
signal_b_read <= '0'; -- #
|
||||
signal_write <= '0'; -- #
|
||||
|
||||
case current_task_state is -- #
|
||||
when work.task.TASK_IDLE =>
|
||||
index <= 0;
|
||||
current_add_state <= ADD_IDLE; -- #
|
||||
add_start <= '0'; -- #
|
||||
signal_write <= '0';
|
||||
|
||||
when work.task.TASK_RUNNING =>
|
||||
case current_add_state is -- #
|
||||
when ADD_IDLE => -- #
|
||||
add_start <= '1'; -- #
|
||||
current_add_state <= ADD_WAIT_DONE; -- #
|
||||
|
||||
when ADD_WAIT_DONE => -- #
|
||||
if ( add_done = '1' ) then -- #
|
||||
add_start <= '0'; -- #
|
||||
signal_write <= '1'; -- #
|
||||
signal_writedata <= add_sum; -- #
|
||||
signal_a_read <= '1'; -- #
|
||||
signal_b_read <= '1'; -- #
|
||||
current_add_state <= ADD_WRITE; -- #
|
||||
end if; -- #
|
||||
|
||||
when ADD_WRITE => -- #
|
||||
if ( index < work.task.STREAM_LEN - 2 ) then -- #
|
||||
index <= index + 1; -- #
|
||||
current_add_state <= ADD_IDLE; -- #
|
||||
else -- #
|
||||
current_add_state <= ADD_FINISH; -- #
|
||||
end if; -- #
|
||||
|
||||
when ADD_FINISH => -- #
|
||||
add_start <= '1'; -- #
|
||||
if ( add_done = '1' ) then -- #
|
||||
add_start <= '0'; -- #
|
||||
signal_write <= '1'; -- #
|
||||
signal_writedata <= add_sum; -- #
|
||||
index <= work.task.STREAM_LEN - 1; -- #
|
||||
end if; -- #
|
||||
|
||||
when others => -- #
|
||||
current_add_state <= ADD_IDLE; -- #
|
||||
end case; -- #
|
||||
|
||||
when work.task.TASK_DONE =>
|
||||
index <= 0;
|
||||
current_add_state <= ADD_IDLE; -- #
|
||||
add_start <= '0'; -- #
|
||||
signal_write <= '0';
|
||||
end case;
|
||||
end if;
|
||||
end process sync;
|
||||
|
||||
task_state <= current_task_state;
|
||||
|
||||
end architecture rtl;
|
||||
end architecture rtl;
|
||||
@@ -4,7 +4,28 @@
|
||||
|
||||
int task_add_run( void * task ) {
|
||||
|
||||
// TODO
|
||||
float_word a;
|
||||
|
||||
float_word b;
|
||||
|
||||
float_word c;
|
||||
|
||||
task_base_config * config = (task_base_config *) task;
|
||||
|
||||
for (uint32_t i= 0; i < DATA_CHANNEL_DEPTH; ++i)
|
||||
{
|
||||
|
||||
data_channel_read(config->sources[0], &a.word);
|
||||
data_channel_read(config->sources[1], &b.word);
|
||||
|
||||
c.value = a.value + b.value;
|
||||
|
||||
data_channel_write(config->sink, c.word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,42 @@
|
||||
#include "system/float_word.h"
|
||||
|
||||
int task_rand_run( void * task ) {
|
||||
rand_config * config = (rand_config *) task;
|
||||
uint32_t sink = config->base.sink;
|
||||
data_channel_clear( sink );
|
||||
|
||||
// TODO
|
||||
// Startwert (Seed) als 32-Bit Bitmuster laden
|
||||
float_word current;
|
||||
current.value = config->seed;
|
||||
uint32_t lfsr = current.word;
|
||||
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
|
||||
// 1. Feedback-Bit berechnen (XOR der Taps an Bit 31, 21, 1 und 0)
|
||||
uint32_t bit31 = (lfsr >> 31) & 1;
|
||||
uint32_t bit21 = (lfsr >> 21) & 1;
|
||||
uint32_t bit1 = (lfsr >> 1) & 1;
|
||||
uint32_t bit0 = (lfsr >> 0) & 1;
|
||||
uint32_t feedback = bit31 ^ bit21 ^ bit1 ^ bit0;
|
||||
|
||||
// 2. Register um 1 nach links schieben und Feedback rechts einspeisen
|
||||
lfsr = (lfsr << 1) | feedback;
|
||||
|
||||
// 3. Kopie anlegen und Exponentenbereich auf dieser Kopie anpassen
|
||||
float_word res;
|
||||
res.word = lfsr;
|
||||
|
||||
if ( (res.word >> 30) & 1 ) {
|
||||
// Wenn Bit 30 == 1: Bits 29..24 auf 0 setzen
|
||||
res.word &= ~(0b00111111 << 24);
|
||||
} else {
|
||||
// Wenn Bit 30 == 0: Bits 29..25 auf 1 setzen
|
||||
res.word |= (0b00011111 << 25);
|
||||
}
|
||||
|
||||
// 4. Fertigen Wert in den Datenkanal schreiben
|
||||
data_channel_write( sink, res.word );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,38 @@
|
||||
#include "system/task_sine.h"
|
||||
#include "system/hardware_task.h"
|
||||
#include "system/sine_config.h"
|
||||
#include "system/data_channel.h"
|
||||
#include "system/float_word.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <system.h>
|
||||
|
||||
|
||||
int task_sine_run( void * data ) {
|
||||
|
||||
// TODO
|
||||
sine_config * task = ( sine_config * ) data;
|
||||
uint32_t data_channel_base = task->base.sink;
|
||||
data_channel_clear( data_channel_base );
|
||||
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
float_word res;
|
||||
|
||||
//
|
||||
res.value = task->amplitude * // AMPLITUDE DER WELLE FESTLEGEN
|
||||
sinf(
|
||||
( 2.0f * M_PI * i ) // 1. UMRECHNUNG IN BOGENMAß
|
||||
/ ( float )task->samples_per_periode // 2. ANZAHL DER SAMPLES PRO PERIODE
|
||||
|
||||
+ task->phase // PHASENVERSCHIEBUNG ADDIEREN
|
||||
);
|
||||
//
|
||||
|
||||
|
||||
|
||||
data_channel_write( data_channel_base, res.word );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user