From 38764943e5fc61c424c018068dc7f6790dddf147 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 02:29:14 +0100 Subject: Format repass. --- include/common.h | 17 +++++++++++++---- include/evolver.h | 23 +++++++++++++++-------- include/instset.h | 12 ++++++++---- include/memory.h | 52 +++++++++++++++++++++++++++++++++------------------- include/process.h | 44 +++++++++++++++++++++++++++++--------------- include/render.h | 8 +++++--- include/salis.h | 24 ++++++++++++++++-------- 7 files changed, 119 insertions(+), 61 deletions(-) (limited to 'include') diff --git a/include/common.h b/include/common.h index 50ac563..2db1258 100644 --- a/include/common.h +++ b/include/common.h @@ -12,24 +12,33 @@ #ifndef SALIS_COMMON_H #define SALIS_COMMON_H -/* Typedef sender functor type for easy python parsing. +/** +* Typedef sender functor type for easy python parsing. */ typedef void (*Sender)(uint8 inst); -/* Typedef receiver functor type for easy python parsing. +/** +* Typedef receiver functor type for easy python parsing. */ typedef uint8 (*Receiver)(void); -/* Set sender functor. When unset, SEND instruction does nothing. +/** +* Set sender functor. When unset, SEND instruction does nothing. * @param sender Sender functor */ SALIS_API void sal_comm_set_sender(Sender sender); -/* Set receiver functor. When unset, RCVE instruction does nothing. +/** +* Set receiver functor. When unset, RCVE instruction does nothing. * @param receiver Receiver functor */ SALIS_API void sal_comm_set_receiver(Receiver receiver); + +/******************************* +* PRIVATES * +*******************************/ + void _sal_comm_send(uint8 inst); uint8 _sal_comm_receive(void); diff --git a/include/evolver.h b/include/evolver.h index 457cd9a..26c7d6a 100644 --- a/include/evolver.h +++ b/include/evolver.h @@ -10,27 +10,34 @@ #ifndef SALIS_EVOLVER_H #define SALIS_EVOLVER_H -void _sal_evo_init(void); -void _sal_evo_quit(void); -void _sal_evo_load_from(FILE *file); -void _sal_evo_save_into(FILE *file); - -/** Get address where the last cosmic ray landed. +/** +* Get address where the last cosmic ray landed. * @return Last address changed by a cosmic ray */ SALIS_API uint32 sal_evo_get_last_changed_address(void); -/** Get amount of random numbers generated during the last simulation cycle. +/** +* Get amount of random numbers generated during the last simulation cycle. * @return Number of calls to the random number generator during the last cycle */ SALIS_API uint32 sal_evo_get_calls_on_last_cycle(void); -/** Access the internal state of the XOR-Shift random number generator. +/** +* Access the internal state of the XOR-Shift random number generator. * @param state_index Index of one of the 32 bit state-blocks [0-4] * @return State of the 32 bit block */ SALIS_API uint32 sal_evo_get_state(uint8 state_index); + +/******************************* +* PRIVATES * +*******************************/ + +void _sal_evo_init(void); +void _sal_evo_quit(void); +void _sal_evo_load_from(FILE *file); +void _sal_evo_save_into(FILE *file); void _sal_evo_randomize_at(uint32 address); void _sal_evo_cycle(void); diff --git a/include/instset.h b/include/instset.h index a7f4773..cde1498 100644 --- a/include/instset.h +++ b/include/instset.h @@ -12,7 +12,8 @@ #define INST_COUNT 32 -/** Salis instruction set. The 'SALIS_INST' macro and inline doc-comments help +/** +* Salis instruction set. The 'SALIS_INST' macro and inline doc-comments help * python parse this file. Don't edit these unless you know what you're doing! */ enum { @@ -50,19 +51,22 @@ enum { SALIS_INST POPN /**< ~ Pop value from stack */ }; -/** Determine if an unsigned integer contains a valid instruction. +/** +* Determine if an unsigned integer contains a valid instruction. * @param byte Any unsigned integer up to 32 bits * @return Whether or nor integer contains a valid instruction */ SALIS_API boolean sal_is_inst(uint32 word); -/** Determine if instruction is a template constructor [NOP0-NOP1]. +/** +* Determine if instruction is a template constructor [NOP0-NOP1]. * @param inst Must contain a valid instruction * @return Whether or not instruction is a template constructor */ SALIS_API boolean sal_is_template(uint32 inst); -/** Determine if instruction a register modifier [MOD0-MOD3]. +/** +* Determine if instruction a register modifier [MOD0-MOD3]. * @param inst Must contain a valid instruction * @return Whether or not instruction is a register modifier */ diff --git a/include/memory.h b/include/memory.h index 6376d7c..e144228 100644 --- a/include/memory.h +++ b/include/memory.h @@ -13,75 +13,89 @@ #define ALLOCATED_FLAG 0x20 #define INSTRUCTION_MASK 0x1f -void _sal_mem_init(uint32 order); -void _sal_mem_quit(void); -void _sal_mem_load_from(FILE *file); -void _sal_mem_save_into(FILE *file); - -/** Get memory order. +/** +* Get memory order. * @return Order of memory (memory_size == 1 << order) */ SALIS_API uint32 sal_mem_get_order(void); -/** Get memory size. +/** +* Get memory size. * @return Size of memory (memory_size == 1 << order) */ SALIS_API uint32 sal_mem_get_size(void); -/** Get amount of addresses with the allocated flag set on them. +/** +* Get amount of addresses with the allocated flag set on them. * @return Amount of addresses with the allocated flag set */ SALIS_API uint32 sal_mem_get_allocated(void); -/** Get memory capacity. +/** +* Get memory capacity. * @return Memory capacity (capacity == size / 2) */ SALIS_API uint32 sal_mem_get_capacity(void); -/** Get amount of addresses with a given instruction written on them. +/** +* Get amount of addresses with a given instruction written on them. * @param inst Instruction whose amount we want to count * @return Amount of addresses with given instruction */ SALIS_API uint32 sal_mem_get_inst_count(uint8 inst); -/** Determine if memory is above its capacity. +/** +* Determine if memory is above its capacity. * @return Memory is above capacity */ SALIS_API boolean sal_mem_is_over_capacity(void); -/** Check validity of address. +/** +* Check validity of address. * @param address Address being queried * @return Validity of address (validity == address < size) */ SALIS_API boolean sal_mem_is_address_valid(uint32 address); -/** Check if given address has the allocated flag set. +/** +* Check if given address has the allocated flag set. * @param address Address being queried * @return Allocated flag is set on this address */ SALIS_API boolean sal_mem_is_allocated(uint32 address); -void _sal_mem_set_allocated(uint32 address); -void _sal_mem_unset_allocated(uint32 address); - -/** Get current instruction at address. +/** +* Get current instruction at address. * @param address Address being queried * @return Instruction currently written at address */ SALIS_API uint8 sal_mem_get_inst(uint32 address); -/** Write instruction into address. +/** +* Write instruction into address. * @param address Address being set * @param inst Instruction to write at given address */ SALIS_API void sal_mem_set_inst(uint32 address, uint8 inst); -/** Get current byte at address. +/** +* Get current byte at address. * @param address Address being queried * @return Byte currently written at address (includes alloc-flag & instruction) */ SALIS_API uint8 sal_mem_get_byte(uint32 address); + +/******************************* +* PRIVATES * +*******************************/ + +void _sal_mem_init(uint32 order); +void _sal_mem_quit(void); +void _sal_mem_load_from(FILE *file); +void _sal_mem_save_into(FILE *file); +void _sal_mem_set_allocated(uint32 address); +void _sal_mem_unset_allocated(uint32 address); void _sal_mem_cycle(void); #endif diff --git a/include/process.h b/include/process.h index 26772c3..aa017c6 100644 --- a/include/process.h +++ b/include/process.h @@ -11,7 +11,8 @@ #ifndef SALIS_PROCESS_H #define SALIS_PROCESS_H -/** The Process data-structure. The 'SALIS_PROC_ELEMENT' macro helps python +/** +* The Process data-structure. The 'SALIS_PROC_ELEMENT' macro helps python * parse the struct, so don't change it! */ struct Process @@ -31,59 +32,72 @@ struct Process typedef struct Process Process; -void _sal_proc_init(void); -void _sal_proc_quit(void); -void _sal_proc_load_from(FILE *file); -void _sal_proc_save_into(FILE *file); - -/** Get process count. +/** +* Get process count. * @return Amount of running (living) processes */ SALIS_API uint32 sal_proc_get_count(void); -/** Get reaper queue capacity. +/** +* Get reaper queue capacity. * @return Currently allocated size of reaper queue */ SALIS_API uint32 sal_proc_get_capacity(void); -/** Get first process. +/** +* Get first process. * @return Process currently on top of reaper queue */ SALIS_API uint32 sal_proc_get_first(void); -/** Get last process. +/** +* Get last process. * @return Process currently on bottom of reaper queue (closest to death) */ SALIS_API uint32 sal_proc_get_last(void); -/** Check if process is currently free. +/** +* Check if process is currently free. * @param proc_id ID of process whose status we want to check * @return Status (either free or running) of the process with the given ID */ SALIS_API boolean sal_proc_is_free(uint32 proc_id); -/** Get process. +/** +* Get process. * @param proc_id ID of Process being queried * @return A copy of the process with the given ID */ SALIS_API Process sal_proc_get_proc(uint32 proc_id); -/** Get process data. +/** +* Get process data. * @param proc_id ID of Process being queried * @param buffer Pre-allocated buffer to store data on [ > sizeof(Process)] */ SALIS_API void sal_proc_get_proc_data(uint32 proc_id, uint32_p buffer); -/** Create new process. +/** +* Create new process. * @param address Address we want to allocate our process into * @param mb1_size Size of the memory block we want to allocate for our process */ SALIS_API void sal_proc_create(uint32 address, uint32 mb1_size); -/** Kill process on bottom of reaper queue. +/** +* Kill process on bottom of reaper queue. */ SALIS_API void sal_proc_kill(void); + +/******************************* +* PRIVATES * +*******************************/ + +void _sal_proc_init(void); +void _sal_proc_quit(void); +void _sal_proc_load_from(FILE *file); +void _sal_proc_save_into(FILE *file); void _sal_proc_cycle(void); #endif diff --git a/include/render.h b/include/render.h index b48fb8f..9a659c4 100644 --- a/include/render.h +++ b/include/render.h @@ -10,7 +10,8 @@ #ifndef SALIS_RENDER_H #define SALIS_RENDER_H -/** Render a 1D image of a given block of memory. This is useful, as rendering +/** +* Render a 1D image of a given block of memory. This is useful, as rendering * directly in python would be too slow. We use openmp for multi-threaded image * generation. * @@ -19,7 +20,8 @@ * @param buff_size Amount of pixels (cells) to be generated * @param buffer Pre-allocated buffer to store the rendered pixels into */ -SALIS_API void sal_ren_get_image(uint32 origin, uint32 cell_size, - uint32 buff_size, uint8_p buffer); +SALIS_API void sal_ren_get_image( + uint32 origin, uint32 cell_size, uint32 buff_size, uint8_p buffer +); #endif diff --git a/include/salis.h b/include/salis.h index 75ef9dd..4394cdb 100644 --- a/include/salis.h +++ b/include/salis.h @@ -20,41 +20,49 @@ #include #include -/** Initialize Salis simulation. +/** +* Initialize Salis simulation. * @param order Order of memory (memory_size == 1 << order) */ SALIS_API void sal_main_init(uint32 order); -/** Free resources and quit Salis. +/** +* Free resources and quit Salis. */ SALIS_API void sal_main_quit(void); -/** Load existing Salis simulation from saved file. +/** +* Load existing Salis simulation from saved file. * @param file_name Path of the save file to be loaded */ SALIS_API void sal_main_load(string file_name); -/** Save Salis simulation to a file. +/** +* Save Salis simulation to a file. * @param file_name Path of the save file to be created */ SALIS_API void sal_main_save(string file_name); -/** Check if Salis simulation has been correctly initialized. +/** +* Check if Salis simulation has been correctly initialized. * @return Salis has been correctly initialized */ SALIS_API boolean sal_main_is_init(void); -/** Get current simulation cycle. +/** +* Get current simulation cycle. * @return Current simulation cycle */ SALIS_API uint32 sal_main_get_cycle(void); -/** Get current simulation epoch. +/** +* Get current simulation epoch. * @return Current simulation epoch (1 epoch == 2^32 cycles) */ SALIS_API uint32 sal_main_get_epoch(void); -/** Update simulation once. This will cycle all Salis modules and processes. +/** +* Update simulation once. This will cycle all Salis modules and processes. */ SALIS_API void sal_main_cycle(void); -- cgit v1.2.1