Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the typos and autofomartted #334

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 36 additions & 35 deletions code_producers/src/c_elements/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub struct CProducer {
name_tag: String,
string_table: Vec<String>,
//New for buses
pub num_of_bus_instances: usize, //total number of different bus instances
//pub size_of_bus_fields: usize, //total number of fields in all differen bus intances
pub num_of_bus_instances: usize, //total number of different bus instances
//pub size_of_bus_fields: usize, //total number of fields in all different bus instances
pub busid_field_info: FieldMap, //for every busId (0..num-1) provides de offset, size, dimensions and busId of each field (0..n-1) in it
}

Expand All @@ -42,27 +42,27 @@ impl Default for CProducer {
my_map.insert(
0,
vec![
IODef { code: 0, offset: 0, lengths: [2, 3].to_vec(), size: 6, bus_id:None },
IODef { code: 1, offset: 6, lengths: [].to_vec(), size: 1, bus_id:None },
IODef { code: 2, offset: 7, lengths: [2].to_vec(), size: 2, bus_id:None },
IODef { code: 0, offset: 0, lengths: [2, 3].to_vec(), size: 6, bus_id: None },
IODef { code: 1, offset: 6, lengths: [].to_vec(), size: 1, bus_id: None },
IODef { code: 2, offset: 7, lengths: [2].to_vec(), size: 2, bus_id: None },
],
);
my_map.insert(
1,
vec![
IODef { code: 0, offset: 0, lengths: [3].to_vec(), size: 3, bus_id:None },
IODef { code: 1, offset: 3, lengths: [4, 8, 6].to_vec(), size: 192, bus_id:None },
IODef { code: 0, offset: 0, lengths: [3].to_vec(), size: 3, bus_id: None },
IODef { code: 1, offset: 3, lengths: [4, 8, 6].to_vec(), size: 192, bus_id: None },
],
);
my_map.insert(
2,
vec![
IODef { code: 0, offset: 0, lengths: [].to_vec(), size: 1, bus_id:None },
IODef { code: 1, offset: 1, lengths: [4].to_vec(), size: 4, bus_id:None },
IODef { code: 2, offset: 5, lengths: [2, 6].to_vec(), size: 12, bus_id:None },
IODef { code: 0, offset: 0, lengths: [].to_vec(), size: 1, bus_id: None },
IODef { code: 1, offset: 1, lengths: [4].to_vec(), size: 4, bus_id: None },
IODef { code: 2, offset: 5, lengths: [2, 6].to_vec(), size: 12, bus_id: None },
],
);

CProducer {
main_header: "Main_0".to_string(),
main_is_parallel: false,
Expand All @@ -74,21 +74,22 @@ impl Default for CProducer {
number_of_main_outputs: 1,
number_of_main_inputs: 2,
main_input_list: [
InputInfo{
name:"in1".to_string(),
size:1,
dimensions: Vec::new(),
start: 2,
bus_id: None
InputInfo {
name: "in1".to_string(),
size: 1,
dimensions: Vec::new(),
start: 2,
bus_id: None,
},
InputInfo{
name:"in2".to_string(),
size:1,
dimensions: Vec::new(),
start: 3,
bus_id: None
InputInfo {
name: "in2".to_string(),
size: 1,
dimensions: Vec::new(),
start: 3,
bus_id: None,
},
].to_vec(),
]
.to_vec(),
signals_in_witness: 20,
witness_to_signal_list: [
0, 1, 2, 3, 4, 5, 6, 12, 16, 19, 24, 27, 33, 42, 46, 50, 51, 65, 78, 79,
Expand Down Expand Up @@ -117,9 +118,9 @@ impl Default for CProducer {
name_tag: "name".to_string(),
string_table: Vec::new(),
//New for buses
num_of_bus_instances: 0,
// size_of_bus_fields: 0,
busid_field_info: Vec::new(),
num_of_bus_instances: 0,
// size_of_bus_fields: 0,
busid_field_info: Vec::new(),
}
}
}
Expand Down Expand Up @@ -150,20 +151,20 @@ impl CProducer {
&self.prime
}
pub fn get_number_of_main_outputs(&self) -> usize {
self.number_of_main_outputs+1
self.number_of_main_outputs + 1
}
pub fn get_number_of_main_inputs(&self) -> usize {
self.number_of_main_inputs
}
pub fn get_main_input_list(&self) -> &InputList {
&self.main_input_list
}
//<<<<<<< HEAD
//=======
//<<<<<<< HEAD
//=======
pub fn get_input_hash_map_entry_size(&self) -> usize {
std::cmp::max(usize::pow(2,(self.main_input_list.len() as f32).log2().ceil() as u32),256)
}
//>>>>>>> 9f3da35a8ac3107190f8c85c8cf3ea1a0f8780a4
std::cmp::max(usize::pow(2, (self.main_input_list.len() as f32).log2().ceil() as u32), 256)
}
//>>>>>>> 9f3da35a8ac3107190f8c85c8cf3ea1a0f8780a4
pub fn get_number_of_witness(&self) -> usize {
self.signals_in_witness
}
Expand Down Expand Up @@ -205,12 +206,12 @@ impl CProducer {
pub fn set_string_table(&mut self, string_table: Vec<String>) {
self.string_table = string_table;
}

//New for buses
pub fn get_number_of_bus_instances(&self) -> usize {
self.num_of_bus_instances
}

pub fn get_busid_field_info(&self) -> &FieldMap {
&self.busid_field_info
}
Expand Down
90 changes: 46 additions & 44 deletions code_producers/src/wasm_elements/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ pub struct WASMProducer {
create_loop_offset_tag: String,
create_loop_counter_tag: String,
merror_tag: String,
string_table: Vec<String>,
string_table: Vec<String>,
//New for buses
pub num_of_bus_instances: usize, //total number of different bus instances
// pub size_of_bus_fields: usize, //total number of fields in all differen bus intances ???
pub num_of_bus_instances: usize, //total number of different bus instances
// pub size_of_bus_fields: usize, //total number of fields in all different bus instances ???
pub busid_field_info: FieldMap, //for every busId (0..num-1) provides de offset, the dimensions and size of each field (0..n-1) in it
}

Expand All @@ -82,22 +82,23 @@ impl Default for WASMProducer {
number_of_main_outputs: 0, //2,
number_of_main_inputs: 0, // 4,
main_input_list: [
InputInfo{
name:"in1".to_string(),
size:1,
dimensions: Vec::new(),
start: 1,
bus_id: None
InputInfo {
name: "in1".to_string(),
size: 1,
dimensions: Vec::new(),
start: 1,
bus_id: None,
},
InputInfo{
name:"in2".to_string(),
size:1,
dimensions: Vec::new(),
start: 2,
bus_id: None
}
].to_vec(),
signals_in_witness: 0, //20,
InputInfo {
name: "in2".to_string(),
size: 1,
dimensions: Vec::new(),
start: 2,
bus_id: None,
},
]
.to_vec(),
signals_in_witness: 0, //20,
witness_to_signal_list: [].to_vec(), //[0,1,2,3,4,5,6,12,16,19,24,27,33,42,46,50,51,65,78,79].to_vec(),
message_list: [].to_vec(), //["Main".to_string(),"Hola Herme".to_string(),"Hola Albert".to_string()].to_vec(),
total_number_of_signals: 0, //80,
Expand Down Expand Up @@ -138,13 +139,13 @@ impl Default for WASMProducer {
create_loop_sub_cmp_tag: "$createloopsubcmp".to_string(),
create_loop_offset_tag: "$createloopoffset".to_string(),
create_loop_counter_tag: "$createloopcounter".to_string(),
merror_tag: "$merror".to_string(),
merror_tag: "$merror".to_string(),
string_table: Vec::new(),
//New for buses
num_of_bus_instances: 0,
// size_of_bus_fields: 0,
busid_field_info: Vec::new(),
}
//New for buses
num_of_bus_instances: 0,
// size_of_bus_fields: 0,
busid_field_info: Vec::new(),
}
}
}

Expand Down Expand Up @@ -204,11 +205,11 @@ impl WASMProducer {
pub fn get_main_input_list(&self) -> &InputList {
&self.main_input_list
}
//HEAD
//=======
//HEAD
//=======
pub fn get_input_hash_map_entry_size(&self) -> usize {
std::cmp::max(usize::pow(2,(self.main_input_list.len() as f32).log2().ceil() as u32),256)
//>>>>>>> 9f3da35a8ac3107190f8c85c8cf3ea1a0f8780a4
std::cmp::max(usize::pow(2, (self.main_input_list.len() as f32).log2().ceil() as u32), 256)
//>>>>>>> 9f3da35a8ac3107190f8c85c8cf3ea1a0f8780a4
}
pub fn get_number_of_witness(&self) -> usize {
self.signals_in_witness
Expand Down Expand Up @@ -266,16 +267,16 @@ impl WASMProducer {
let mut n = 0;
for (_c, v) in &self.io_map {
for s in v {
// we take always offset, and size and all lengths but last one if len !=0,
// we take always offset, and size and all lengths but last one if len !=0,
if s.lengths.len() == 0 {
n += 1;
} else {
n += s.lengths.len() + 1;
}
// we take the bus_id if it has type bus
if let Some(_) = &s.bus_id {
n += 1;
}
// we take the bus_id if it has type bus
if let Some(_) = &s.bus_id {
n += 1;
}
}
}
n * 4
Expand All @@ -284,7 +285,7 @@ impl WASMProducer {
pub fn get_number_of_bus_instances(&self) -> usize {
self.num_of_bus_instances
}

pub fn get_number_of_bus_fields(&self) -> usize {
let mut n = 0;
for v in &self.busid_field_info {
Expand All @@ -296,19 +297,19 @@ impl WASMProducer {
pub fn get_size_of_bus_info(&self) -> usize {
let mut n = 0;
for v in &self.busid_field_info {
for s in v {
for s in v {
// since we take offset, busid (if it is) and all lengths but first one and size if not zero
if s.dimensions.len() == 0 {
n += 1;
} else {
n += s.dimensions.len() + 1;
}
if let Some(_) = &s.bus_id {
n += 1;
}
if let Some(_) = &s.bus_id {
n += 1;
}
}
}
n * 4
n * 4
}

pub fn get_busid_field_info(&self) -> &FieldMap {
Expand All @@ -331,7 +332,8 @@ impl WASMProducer {
(4 * self.size_32_bit) + 8 + self.get_shared_rw_memory_start()
}
pub fn get_remaining_input_signal_counter(&self) -> usize {
self.get_input_signals_hashmap_start() + self.get_input_hash_map_entry_size()*16 // input_hash_map_entry_size*(8(h)+4(pos)+4(size))
self.get_input_signals_hashmap_start() + self.get_input_hash_map_entry_size() * 16
// input_hash_map_entry_size*(8(h)+4(pos)+4(size))
}
pub fn get_input_signal_set_map_start(&self) -> usize {
self.get_remaining_input_signal_counter() + 4
Expand Down Expand Up @@ -379,7 +381,7 @@ impl WASMProducer {
a + b
}
pub fn get_bus_instance_to_field_start(&self) -> usize {
self.get_io_signals_info_start() + self.get_io_signals_info_size()
self.get_io_signals_info_start() + self.get_io_signals_info_size()
}
pub fn get_field_to_info_start(&self) -> usize {
let a = self.get_bus_instance_to_field_start();
Expand Down Expand Up @@ -407,7 +409,7 @@ impl WASMProducer {
pub fn get_constant_numbers_start(&self) -> usize {
self.get_string_list_start() + self.size_of_message_in_bytes * self.string_table.len()
}

pub fn get_var_stack_memory_start(&self) -> usize {
self.get_constant_numbers_start() + (self.size_32_bit + 2) * 4 * self.field_tracking.len()
}
Expand Down Expand Up @@ -487,9 +489,9 @@ impl WASMProducer {
&self.create_loop_counter_tag
}
pub fn get_merror_tag(&self) -> &str {
&self.merror_tag
&self.merror_tag
}
pub fn needs_comments(&self) -> bool{
pub fn needs_comments(&self) -> bool {
self.wat_flag
}

Expand Down
Loading