Skip to content

Commit 14e54f7

Browse files
committed
remove memory buffer as it crashes due to high memory use
1 parent 52462f8 commit 14e54f7

File tree

6 files changed

+24
-224
lines changed

6 files changed

+24
-224
lines changed

ODIN_II/SRC/include/AtomicBuffer.hpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,12 @@
55
#include <bitset>
66
#include <mutex>
77

8-
/**
9-
* DO NOT CHANGE THESE
10-
* we use a single 64 bit integer to store al the value and we bit mask into it
11-
* 2 bits per value gives us a buffer of 32
12-
*
13-
*/
14-
#define BUFFER_SIZE 16
15-
#define CONCURENCY_LIMIT (BUFFER_SIZE-2) // access to cycle -1 with an extra pdding cell
16-
#define DATA_TYPE_BIT_SIZE 2
8+
#define BUFFER_SIZE 2
9+
#define CONCURENCY_LIMIT (BUFFER_SIZE-1) // access to cycle -1 with an extra pdding cell
10+
#define DATA_TYPE_BIT_SIZE 2 // we only need 2 bits to store all the possible values
1711
#define BUFFER_BIT_SIZE (BUFFER_SIZE*DATA_TYPE_BIT_SIZE)
1812

1913

20-
/**
21-
* we only need 2 bits to store the 4 possible values
22-
*/
23-
#define INT_0 0x0
24-
#define INT_1 0x1
25-
#define INT_X 0x2
26-
2714
/**
2815
* Odin use -1 internally, so we need to go back on forth
2916
* TODO: change the default odin value to match both the Blif value and this buffer
@@ -77,9 +64,7 @@ class AtomicBuffer
7764

7865
return_t to_bit(data_t value_in)
7966
{
80-
if(value_in == 0) return INT_0;
81-
else if(value_in == 1) return INT_1;
82-
else return INT_X;
67+
return value_in; // cast to 11 a -1
8368
}
8469

8570
data_t to_value(return_t bit_in)
@@ -98,11 +83,6 @@ class AtomicBuffer
9883
this->set_bits(value_to_set, this->mod_cycle(i),false);
9984
}
10085

101-
AtomicBuffer()
102-
{
103-
this->update_cycle(-1);
104-
}
105-
10686
AtomicBuffer(data_t value_in)
10787
{
10888
this->update_cycle(-1);

ODIN_II/SRC/include/AtomicRam.hpp

Lines changed: 0 additions & 84 deletions
This file was deleted.

ODIN_II/SRC/include/AtomicRow.hpp

Lines changed: 0 additions & 97 deletions
This file was deleted.

ODIN_II/SRC/include/types.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ OTHER DEALINGS IN THE SOFTWARE.
2929
#include "AtomicBuffer.hpp"
3030
#include <mutex>
3131
#include <atomic>
32-
#include "AtomicRam.hpp"
3332

3433
#include <stdlib.h>
3534

@@ -494,7 +493,7 @@ struct nnode_t_t
494493

495494
netlist_t* internal_netlist; // this is a point of having a subgraph in a node
496495

497-
std::unique_ptr<AtomicRam> memory_data;
496+
std::vector<std::vector<signed char>> memory_data;
498497

499498
//(int cycle, int num_input_pins, npin_t *inputs, int num_output_pins, npin_t *outputs);
500499
void (*simulate_block_cycle)(int, int, int*, int, int*);

ODIN_II/SRC/odin_ii.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ void get_options(int argc, char** argv) {
549549
int thread_requested = global_args.parralelized_simulation;
550550
int max_thread = std::thread::hardware_concurrency();
551551
global_args.parralelized_simulation.set(
552-
std::min( std::min( CONCURENCY_LIMIT, max_thread ),
552+
std::min( std::min(CONCURENCY_LIMIT, max_thread) ,
553553
std::max(1, thread_requested))
554554
,argparse::Provenance::SPECIFIED);
555555

ODIN_II/SRC/simulate_blif.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ sim_data_t *init_simulation(netlist_t *netlist)
327327
{
328328
//for multithreading
329329
used_time = std::numeric_limits<double>::max();
330-
number_of_workers = std::min(CONCURENCY_LIMIT, std::max(1, global_args.parralelized_simulation.value()));
331-
if(global_args.parralelized_simulation.value() >1 )
332-
warning_message(SIMULATION_ERROR,-1,-1,"Executing simulation with maximum of %d threads", global_args.parralelized_simulation.value());
330+
number_of_workers = global_args.parralelized_simulation.value();
331+
if(number_of_workers >1 )
332+
warning_message(SIMULATION_ERROR,-1,-1,"Executing simulation with maximum of %d threads", number_of_workers);
333333

334334

335335
found_best_time = false;
@@ -2118,18 +2118,20 @@ static void read_write_to_memory(nnode_t *node , signal_list_t *input_address, s
21182118
* make a single trigger out of write_enable pin and if it was a positive edge
21192119
*/
21202120
bool write = (trigger && 1 == get_pin_value(write_enabled, cycle));
2121+
bool address_is_valid = (address >= 0 && address < node->memory_data.size());
21212122

2122-
std::vector<signed char> previous_values = node->memory_data->get_word_line(address, cycle-1);
2123-
std::vector<signed char> new_values;
21242123
for (size_t i = 0; i < data_out->count; i++)
21252124
{
2126-
// we hook onto the ff function to both read and update since memories are flip flops
2127-
new_values.push_back(compute_ff(write, data_in->pins[i], previous_values[i], cycle));
2125+
signed char new_value = -1;
2126+
if(address_is_valid)
2127+
{
2128+
// we hook onto the ff function to both read and update since memories are flip flops
2129+
new_value = compute_ff(write, data_in->pins[i], node->memory_data[address][i], cycle);
2130+
node->memory_data[address][i] = new_value;
2131+
}
21282132
// output is combinational so it always grabs latest value
2129-
update_pin_value(data_out->pins[i], new_values.back(), cycle);
2133+
update_pin_value(data_out->pins[i], new_value, cycle);
21302134
}
2131-
2132-
node->memory_data->set_word_line(address, new_values, cycle);
21332135
}
21342136

21352137
/*
@@ -2141,10 +2143,9 @@ static void compute_single_port_memory(nnode_t *node, int cycle)
21412143

21422144
bool trigger = ff_trigger(RISING_EDGE_SENSITIVITY, signals->clk, cycle);
21432145

2144-
if (node->memory_data == nullptr || node->memory_data->empty())
2146+
if (node->memory_data.empty())
21452147
instantiate_memory(node, signals->data->count, signals->addr->count);
21462148

2147-
node->memory_data->copy_ram_foward_one_cycle(cycle);
21482149

21492150
read_write_to_memory(node, signals->addr, signals->out, signals->data, trigger, signals->we, cycle);
21502151

@@ -2159,13 +2160,12 @@ static void compute_dual_port_memory(nnode_t *node, int cycle)
21592160
dp_ram_signals *signals = get_dp_ram_signals(node);
21602161
bool trigger = ff_trigger(RISING_EDGE_SENSITIVITY, signals->clk, cycle);
21612162

2162-
if (node->memory_data == nullptr || node->memory_data->empty())
2163+
if (node->memory_data.empty())
21632164
instantiate_memory(node,
21642165
std::max(signals->data1->count, signals->data2->count),
21652166
std::max(signals->addr1->count,signals->addr2->count)
21662167
);
21672168

2168-
node->memory_data->copy_ram_foward_one_cycle(cycle);
21692169

21702170
read_write_to_memory(node, signals->addr1, signals->out1, signals->data1, trigger, signals->we1, cycle);
21712171
read_write_to_memory(node, signals->addr2, signals->out2, signals->data2, trigger, signals->we2, cycle);
@@ -2179,7 +2179,8 @@ static void compute_dual_port_memory(nnode_t *node, int cycle)
21792179
*/
21802180
static void instantiate_memory(nnode_t *node, int data_width, int addr_width)
21812181
{
2182-
node->memory_data = std::make_unique<AtomicRam>(addr_width, data_width, init_value(node));
2182+
long max_address = 1 << addr_width;
2183+
node->memory_data = std::vector<std::vector<signed char>>(max_address, std::vector<signed char>(data_width, init_value(node)));
21832184
char *filename = get_mif_filename(node);
21842185

21852186
FILE *mif = fopen(filename, "r");
@@ -2305,7 +2306,8 @@ static void assign_memory_from_mif_file(nnode_t *node, FILE *mif, char *filename
23052306
error_message(SIMULATION_ERROR, line_number, -1, "%s: address %s is out of range.", filename, address_string);
23062307

23072308
// Write the parsed value string to the memory location.
2308-
node->memory_data->init_word_line(address, binary_data, width);
2309+
for(int i=0; i<width; i++)
2310+
node->memory_data[address][i] = binary_data[i] - '0';
23092311
}
23102312
else
23112313
{

0 commit comments

Comments
 (0)